Metamask: Metamask just started throwing a -32000 error for gas estimation via web3.js
Metamask: Critical bug in gas estimation via Web3.js
A recent update to the Metamask wallet has introduced a critical bug that can lead to significant gas costs for users when deploying contracts on the Ethereum network. The issue affects gas estimation, which is essential for accurately tracking the cost of executing smart contract transactions.
Issue: -32000 gas estimation bug
When using Web3.js to interact with the Ethereum blockchain, Metamask provides an estimate of the gas cost required for a particular transaction or operation. However, starting with version 2.0.5, the wallet has introduced a new bug when attempting to perform gas estimation using this method.
Error: -32000
When you encounter the following code in your contract deployment script:
const gasAmount = await this.factory.methods.createContract(
Math.floor(new Date(contract.expirationDate).getTime() / 1000),
//...
);
When attempting to execute gasAmount
, the following error may occur:
>
TypeError: Error in EstimateGas
Impact on User Experience
Error -32000 can result in significant gas costs for users that may not be in line with the user’s expectations or budget. This issue can also cause frustration and increased stress during contract deployment, especially if users rely on Metamask for seamless transactions.
Conclusion
As a user of this code, you should have noticed this critical bug in gas estimation via Web3.js since version 2.0.5 of the Metamask wallet. This issue affects users who have been successfully using the code for a longer period of time than you.
To mitigate this issue, we recommend that you update your contract deployment script to use a different gas cost estimation method, such as:
- Ethers.js: A popular library for interacting with the Ethereum blockchain that provides accurate and reliable gas estimation.
- ContractKit: An open source library for building smart contracts on the Ethereum network that offers robust gas estimation features.
Mitigation Strategy
To minimize the impact of this bug, you can:
- Update your code to use a different gas cost estimation method.
- Monitor gas estimates in real time using Ethers.js or ContractKit.
- Be careful when deploying contracts on the Ethereum network and verify the accuracy of gas estimates before deploying.
Next Steps
If you encounter any further issues related to this error, please feel free to contact our support team for assistance or guidance. We are committed to providing accurate information and helping users like you navigate the complexities of smart contract development on the Ethereum blockchain.
By taking proactive steps to resolve this issue, you can ensure a smoother user experience and reduce the likelihood of gas estimation errors in Metamask.