1

This is my send code:

window.videoContract.methods
    .mint(account, 'https://ipfs.io/ipfs/QmRQC1...')
    .send({
        from: account,
        gas: 20100000
    });

If I set it too high, I get this error: ALERT: [ethjs-query] while formatting outputs from RPC '{"value":{"code":-32603,"data":{"code":-32000,"message":"exceeds block gas limit"}}}'

If I set it too low, the transaction fails with out of gas error: https://explorer-mumbai.maticvigil.com/tx/0x79d96c3a0d9f920d75e17d034c3c0452b8b25fc3395d5595d9b2999fa0602f45/internal-transactions

1 Answer 1

2

Usually it is safe to leave the gas estimation for the wallet itself and not to try to do it yourself.

In the case wallets cannot estimate the gas, which sometimes happens for complex transactions, you can do test transactions on testnet and figure out how many gas units the transactions spend and then use that as a hardcoded limit.

3
  • 1
    Something must have gone wrong with my contracts. If I take the gas and gasPrice settings out, I get this error in Metamask. "ALERT: Transaction Error. Exception thrown in contract code." Apr 10, 2021 at 9:03
  • But does the transaction actually work? Apr 10, 2021 at 9:10
  • No it doesn't. I found out that my contract json files in the web project was not updated, so it was not in sync with the latest version of the contract. All good now. Thanks. Apr 10, 2021 at 9:38

Your Answer

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

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