Issue with Cannot Estimate Gas Error
See original GitHub issueEthers Version
5.4.7
Search Terms
No response
Describe the Problem
Apologize that there isn’t a better category for opening this question/issue:
I wanted to know why I need to provide gas price or gas limit overrides for an external/view contract function if they don’t require gas and are not being performed inside another transaction? And, no other processing is occurring in the function but returning contract state variables.
function getDetails() external view returns ( uint256, uint256, uint256, address, uint256 )
I encountered the “cannot estimate gas; transaction may fail or may require manual gas limit” error originally. It also required that I use a signer and not just a provider when creating the contract instance.
To make it worse, once I switched to a signer, and provided those overrides
const overrides = { gasPrice: ethers.utils.parseUnits(“50000000000”, “wei”), gasLimit: ethers.utils.parseUnits(“100000000000”, “wei”) };
const response = await contract.getDetails(overrides);
I receive an insufficient funds error (Rinkeby) when I have .6 ETH on the account:
Error: insufficient funds for intrinsic transaction cost [ See: https://links.ethers.org/v5-errors-INSUFFICIENT_FUNDS ] (error={“code”:-32000,“message”:“err: insufficient funds for gas * price + value: address 0xc0Eb169794B18685a67C0a998292D184Ddeaeba3 have 600000000000000000 want 200000000000000000000000 (supplied gas 500000000)”}, method=“call”, transaction={“from”:“0xc0Eb169794B18685a67C0a998292D184Ddeaeba3”,“gasLimit”:{“type”:“BigNumber”,“hex”:“0x058d15e176280000”},“gasPrice”:{“type”:“BigNumber”,“hex”:“0x016bcc41e90000”},“to”:“0x5FbDB2315678afecb367f032d93F642f64180aa3”,“data”:“0x936afab3”,“accessList”:null}, code=INSUFFICIENT_FUNDS, version=providers/5.4.5)
Code Snippet
const overrides = {
gasPrice: ethers.utils.parseUnits("50000000000", "wei"),
gasLimit: ethers.utils.parseUnits("100000000000", "wei")
};
const response = await contract.getDetails(overrides);
Contract ABI
No response
Errors
Error: insufficient funds for intrinsic transaction cost [ See: https://links.ethers.org/v5-errors-INSUFFICIENT_FUNDS ] (error={"code":-32000,"message":"err: insufficient funds for gas * price + value: address 0xc0Eb169794B18685a67C0a998292D184Ddeaeba3 have 600000000000000000 want 200000000000000000000000 (supplied gas 500000000)"}, method="call", transaction={"from":"0xc0Eb169794B18685a67C0a998292D184Ddeaeba3","gasLimit":{"type":"BigNumber","hex":"0x058d15e176280000"},"gasPrice":{"type":"BigNumber","hex":"0x016bcc41e90000"},"to":"0x5FbDB2315678afecb367f032d93F642f64180aa3","data":"0x936afab3","accessList":null}, code=INSUFFICIENT_FUNDS, version=providers/5.4.5)
Environment
Hardhat
Environment (Other)
No response
Issue Analytics
- State:
- Created a year ago
- Comments:14 (1 by maintainers)
Top GitHub Comments
Yep. Thanks @ricmoo
Thanks @bobanm for the help and the honest feedback.