I create a smart contract using ink! v4.2 and deploy it using contracts-ui.substrate.io Then in my front (which uses @polkadot/api-contract: 10.7.2, @polkadot/api: 10.7.2) I run this code:

await ApiPromise.create({ new WsProvider("wss://ws.test.azero.dev"), signer: connectedAccount });
const contract = new ContractPromise(api, abiDataJson, contractAddress);


api: is correct for sure

abiDataJson: json generated in /target/ink after run cargo contract build --release

contractAddress: obtained in contracts-ui.substrate.io in the part that shows "You instantiated this contract 5...", just below the title of the smart contract name

And when I run

const { gasRequired, storageDeposit, result, output } = await contract.query.totalSupply(account.address, { gasLimit: -1, storageDepositLimit: null });
console.log('result.toHuman(): ', result.toHuman());
console.log("output: ", output);

I obtain

result.toHuman():  {Err: {…}}
output: null

I think the error might be related to contractAddress, because if I put a different addres I get the same thing. In addition, the smart contract is deployed successfully as it works by calling it from contracts-ui.substrate.io

Anybody know where the error is? Thanks in advance :)

1 Answer 1


I finally figured it out! The -1 value of gasLimit is generating the error. I solve it by modifying it in the following way:

const gasLimit = api.registry.createType('WeightV2', { refTime: 3912368128, proofSize: 131072 });

Where refTime and proofSize values are obtained using contracts-ui.substrate.io

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.