I upgraded my project to ink4.0.0, and upgrate @polkadot/api-contract to the latest version, then I encountered an error when sending transaction.

Error: createType(Call):: Call: failed decoding contracts.call:: Struct: failed on args: {"dest":"MultiAddress","value":"Lookup78","gas_limit":"Lookup93","storage_deposit_limit":"Option<Compact<u128>>","data":"Bytes"}:: Struct: failed on gas_limit: Compact<Weight>:: u64: Negative number passed to unsigned type


My code is like this

let value = 0;
let gasLimit = -1;
await contract.tx[methodName]({ value, gasLimit }, ...arguments).signAndSend(sender, (result) => {
    if (result.status.isInBlock) {
        console.log('in a block');
    } else if (result.status.isFinalized) {

It worked well for ink3.0.

I wonder if I have to estimate gas in ink4.0.0, or I can set gaslimit 10**12?

1 Answer 1


-1 is not a valid value for a transaction. For a transaction you should dry run the contract first and set the gas_limit for the transaction to the gas_required field as returned by the dry run.

As a side node: -1 is not a valid value for the dry run either as it is an unsigned number in substrate. I assume polkadot.js transforms this -1 into some big number for you.

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.