question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Contract revert reasons can mimic node errors

See original GitHub issue

Ethers Version

5.6.4

Search Terms

insufficient funds, insufficient funds for intrinsic transaction cost, error message

Describe the Problem

Given a contract with a require like this one:

require(false, "Insufficient funds")

Ethers will (wrongly) say that the error was “Error: insufficient funds for intrinsic transaction cost”

I guess there’s some pattern matching going on with the returned error message.

This happens even with the hardhat network when a correct data is returned with the encoded error string.

Code Snippet

No response

Contract ABI

No response

Errors

No response

Environment

No response

Environment (Other)

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ricmoocommented, May 2, 2022

Thanks! I’ll look into this asap.

0reactions
se3000commented, Aug 4, 2022

Just ran into this. The code has been unchanged for years. The tests have gone through some tooling changes over the years, but are mostly unchanged. Started failing when we bumped to the latest version of hardhat.

AssertionError: Expected transaction to be reverted with insufficient funds for payment, but other exception was thrown: Error: insufficient funds for intrinsic transaction cost [ See: https://links.ethers.org/v5-errors-INSUFFICIENT_FUNDS ] (error={"stackTrace":[{"type":4,"sourceReference":{"function":"updateFutureRounds","contract":"FluxAggregator","sourceName":"src/v0.6/FluxAggregator.sol","sourceContent":"...","line":263,"range":[9007,9108]},"message":{"value":{"type":"Buffer","data":[8,195,121,160,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,30,105,110,115,117,102,102,105,99,105,101,110,116,32,102,117,110,100,115,32,102,111,114,32,112,97,121,109,101,110,116,0,0]},"_selector":"08c379a0"},"isInvalidOpcodeError":false}],"data":"0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001e696e73756666696369656e742066756e647320666f72207061796d656e740000","transactionHash":"0x9bfe504c7424e176106affd152054a953f18c187db02f0da032c8fca4666a7e8"}, method="sendTransaction", transaction=undefined, code=INSUFFICIENT_FUNDS, version=providers/5.6.8)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling require/assert failure errors correctly from a Node.JS ...
Since you are calling a view function, the first callback will error, more or less immediately. It's currently possible to return errors ......
Read more >
Error: call revert exception // npm run dev - Stack Overflow
This error (CALL_EXCEPTION) happens when your smart contract is not deployed yet. Wait the transaction ends: await contract.
Read more >
Hardhat Network | Ethereum development environment for ...
When a transaction fails without a reason, Hardhat Network will create a clear error message in the following cases: Calling a non-payable ...
Read more >
Documentation - Ethers.js
It is generally better practice (for security reasons) to copy the ethers ... to a specific contract on the Ethereum Network, so that...
Read more >
Any idea why getBalance in App.js would throw Error
Error: call revert exception (method="balanceOf(address)", ... my contracts and their addresses had changed, so I had to copy-paste the new addresses to the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found