-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Contract revert reasons can mimic node errors #2954
Comments
Thanks! I’ll look into this asap. |
This has been fixed in 5.6.6. Try it out and let me know if you still have any issues. Thanks! :) |
I think this is working correctly when the gas is estimated, but the same problem shows up if you set a specific gas limit in the overrides 😢 |
I thought I tried that too? I’ll test it out again shortly. |
I just tried out all combinations of "view" vs. "send" and "with" vs "without" a gasLimit, and all returned the appropriate error ( Can you provide an example? |
It happens when using Hardhat's node, but it does not happen with One difference I noticed is that, when using geth, I have to do: const tx = await contract.f({ gasLimit: 1_000_000 }) // f reverts with "Insufficient funds" as its revert reason
await tx.wait() But when using Hardhat's node, the transaction reverts immediately (before reaching I should clarify that, while I'm using Hardhat's node, I'm running a script with plain ethers (no hardhat-ethers involved). Does that help? I think it's just a matter of doing the tests you did but using Hardhat's node, but here's the script I used just in case: const ethers = require("ethers");
async function main() {
const provider = new ethers.providers.JsonRpcProvider("http://localhost:8545")
// private key of hardhat's second default account
const signer = new ethers.Wallet("0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d", provider)
// address where I deployed the Foo contract, see below
const contract = new ethers.Contract("0x8464135c8F25Da09e49BC8782676a84730C318bC", ['function f() public'], signer)
const tx = await contract.f({ gasLimit: 1_000_000 });
await tx.wait()
}
main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
}); and the contract: //SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
contract Foo {
function f() public {
require(false, "Insufficient funds");
}
} |
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.
|
Closing older issues. But if this is still happening in v6, please re-open or start a new issue. Thanks! :) |
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:
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
The text was updated successfully, but these errors were encountered: