Ethers still tries to estimate gas even when passing manual gasLimit
See original GitHub issueDescribe the bug
I’m trying to call a contract method with an unpredictable gas limit, however if I try to call it and pass the gasLimit
manually I get get a “Error: cannot estimate gas; transaction may fail or may require manual gas limit” error.
Maybe I’m missing something but shouldn’t ethers skip estimating gas if it’s passed manually?
Reproduction steps You can test with the following contract in rinkeby:
const CONTRACT = "0x10539a06b047259f247f8c622430c22803821A00";
const ABI = [
'function stakeOf(address _owner) public view returns (uint256[] memory)'
];
// using JsonRpcProvider as an example, but I've tried with metamask as well and same issue
const provider =new ethers.providers.JsonRpcProvider(
"provider URL"
);
const signer = provider.getSigner();
const contract = new ethers.Contract(CONTRACT, ABI, signer);
contract.stakeOf("0x73257cE508dBB94Ff78C27381FddD42FB7266Ba4", {
gasLimit: '50000000',
}),
Result
Error: cannot estimate gas; transaction may fail or may require manual gas limit (error={"name":"ProviderError","code":3,"_isProviderError":true,"data":"0x4e487b710000000000000000000000000000000000000000000000000000000000000032"}, method="call", transaction={"from":"0x73257cE508dBB94Ff78C27381FddD42FB7266Ba4","gasLimit":{"type":"BigNumber","hex":"0x02faf080"},"to":"0x10539a06b047259f247f8c622430c22803821A00","data":"0x4262336000000000000000000000000073257ce508dbb94ff78c27381fddd42fb7266ba4","accessList":null}, code=UNPREDICTABLE_GAS_LIMIT, version=providers/5.5.1)
//...
method: 'call',
transaction: {
from: '0x73257cE508dBB94Ff78C27381FddD42FB7266Ba4',
gasLimit: BigNumber { value: "50000000" },
to: '0x10539a06b047259f247f8c622430c22803821A00',
data: '0x4262336000000000000000000000000073257ce508dbb94ff78c27381fddd42fb7266ba4',
accessList: null
}
}
Environment: Node: v14.17.4
This happens in both node and browser environments.
Search Terms gas limit, estimate gas
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
transaction may fail or may require manual gas limit ...
Error: cannot estimate gas; transaction may fail or may require manual gas limit. This error is because the transaction was not complete and ......
Read more >transaction may fail or may require manual gas limit" : r/ethdev
I am trying a mint function that I wrote and getting this error: Error: cannot estimate gas; transaction may fail or may require...
Read more >hardhat cannot estimate gas; transaction may fail or ... - You.com
I am trying to transfer tokens from a contract deployed on the blockchain, ... Error cannot estimate gas; transaction may fail or may...
Read more >Documentation - Ethers.js
gasLimit - the amount of gas (theoretically) to allow a node to use during the execution of the code; since there is no...
Read more >How to re-send a transaction with higher gas price using ...
1. Sometimes, you submit a transaction on Ethereum without enough gas due to network congestion or too m... 2. We do a transaction...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@nataouze I’ve added context to discussion #2849 to help explain what is going on and will be keeping that up to date if you want to hop over there. 😃
Thanks for the fix @ricmoo. I’ve (finally) verified it – see https://github.com/NomicFoundation/hardhat/issues/2248#issuecomment-1250350108