Skip to content

Hardhat Error: "Error: cannot estimate gas" #85

Answered by TatyOko28
houstonTaleubou asked this question in Q&A
Discussion options

You must be logged in to vote

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
Try increasing the gas limit artificially:

await contract.functionName({ gasLimit: 5000000 });

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by houstonTaleubou
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants