cosmjs
cosmjs copied to clipboard
Error: Bad status on response: 400 while uploading contract
I am getting Error: Bad status on response: 400
error while upload cotract using upload
function
below is my code
const wasm = await loadContract(contract);
console.debug(`Uploading ${contract.name}...`);
const receipt = await client.upload(
signer,
wasm,
"auto",
// `Upload ${contract.name}`
);
console.log(receipt);
below is error
Error: Bad status on response: 400
at filterBadStatus (/home/pedalsup/D-drive/Learning/cosmos/frontend/academy-deploy-main/node_modules/@cosmjs/tendermint-rpc/src/rpcclients/httpclient.ts:17:11)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async HttpClient.execute (/home/pedalsup/D-drive/Learning/cosmos/frontend/academy-deploy-main/node_modules/@cosmjs/tendermint-rpc/src/rpcclients/httpclient.ts:87:43)
at async Tendermint34Client.doCall (/home/pedalsup/D-drive/Learning/cosmos/frontend/academy-deploy-main/node_modules/@cosmjs/tendermint-rpc/src/tendermint34/tendermint34client.ts:341:20)
at async QueryClient.queryUnverified (/home/pedalsup/D-drive/Learning/cosmos/frontend/academy-deploy-main/node_modules/@cosmjs/stargate/src/queryclient/queryclient.ts:574:22)
at async Object.simulate (/home/pedalsup/D-drive/Learning/cosmos/frontend/academy-deploy-main/node_modules/@cosmjs/stargate/src/modules/tx/queries.ts:75:26)
at async SigningCosmWasmClient.simulate (/home/pedalsup/D-drive/Learning/cosmos/frontend/academy-deploy-main/node_modules/@cosmjs/cosmwasm-stargate/src/signingcosmwasmclient.ts:231:25)
at async SigningCosmWasmClient.signAndBroadcast (/home/pedalsup/D-drive/Learning/cosmos/frontend/academy-deploy-main/node_modules/@cosmjs/cosmwasm-stargate/src/signingcosmwasmclient.ts:497:29)
at async SigningCosmWasmClient.upload (/home/pedalsup/D-drive/Learning/cosmos/frontend/academy-deploy-main/node_modules/@cosmjs/cosmwasm-stargate/src/signingcosmwasmclient.ts:252:20)
at async uploadContracts (/home/pedalsup/D-drive/Learning/cosmos/frontend/academy-deploy-main/scripts/helpers/uploadContracts.ts:26:21)
Note: my wasm file is around 2.4MB.
2.4MB is more than what most chains can accept. A typical limit of the Wasm file is 800 KB. You can probably get the contract much smaller by using the rust-optimizer.
rust-optimizer reduce contract size from 2.4MB to 327.7kb but now I getting another error
Error: Broadcasting transaction failed with code 2 (codespace: sdk). Log: unable to resolve type URL /cosmwasm.wasm.v1.MsgStoreCode: tx parse error
at SigningCosmWasmClient.broadcastTx (/home/pedalsup/D-drive/Learning/cosmos/frontend/academy-deploy-main/node_modules/@cosmjs/cosmwasm-stargate/src/cosmwasmclient.ts:293:13)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SigningCosmWasmClient.upload (/home/pedalsup/D-drive/Learning/cosmos/frontend/academy-deploy-main/node_modules/@cosmjs/cosmwasm-stargate/src/signingcosmwasmclient.ts:252:20)
at async uploadContracts (/home/pedalsup/D-drive/Learning/cosmos/frontend/academy-deploy-main/scripts/helpers/uploadContracts.ts:25:21)
at async main (/home/pedalsup/D-drive/Learning/cosmos/frontend/academy-deploy-main/scripts/upload_contract.ts:50:18)
error Command failed with exit code 1.
below is my RPC URL and chain-Id
chainId: "theta-testnet-001",
rpcEndpoint:"https://rpc.sentry-01.theta-testnet.polypore.xyz",
can anyone explain above error and how can I solve above error?
The error
unable to resolve type URL /cosmwasm.wasm.v1.MsgStoreCode: tx parse error
sounds like the network has no CosmWasm support. Could you ask the maintainers of the network about it?