Hardhat Error: "Error: cannot estimate gas" #85
Answered
by
TatyOko28
houstonTaleubou
asked this question in
Q&A
-
Why does "Error: cannot estimate gas" appear in Hardhat? |
Beta Was this translation helpful? Give feedback.
Answered by
TatyOko28
Feb 9, 2025
Replies: 1 comment
-
This happens when the contract function being called fails, but the failure reason is unclear. Solution: Debug the transaction with .callStatic() try {
await contract.callStatic.functionName();
} catch (error) {
console.log("Error:", error.reason);
} This will return the exact Solidity error message. Solution: Increase Gas Limit Temporarily await contract.functionName({ gasLimit: 5000000 }); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
houstonTaleubou
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This happens when the contract function being called fails, but the failure reason is unclear.
Solution: Debug the transaction with .callStatic()
This will return the exact Solidity error message.
Solution: Increase Gas Limit Temporarily
Try increasing the gas limit artificially:
await contract.functionName({ gasLimit: 5000000 });