13 Feb 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 revealed a critical bug that could cause users to incur significant gas costs when deploying contracts on the Ethereum network. This issue affects gas valuation, which is necessary to accurately track the cost of executing smart contract transactions.
Problem: gas estimation error -32000
When using Web3.js to interact with the Ethereum blockchain, Metamask provides an estimate of the gas costs required for a specific transaction or operation. However, starting with version 2.0.5, the wallet gave a new error when trying to estimate gas using this method.
Error: -32000
If you encounter the following code in the contract deployment script:
const gasAmount = expect this.factory.methods.createContract(
Math.floor(new Date(contract.expirationDate).getTime() / 1000),
// ...
);
When trying to run gasAmount
, you may encounter the following error:
>
TypeError: Error in EstimateGas
Impact on user experience
The -32000 error can result in significant gas costs for users that may not meet the user’s expectations or budget. This problem can also lead to 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 be aware of this critical bug in gas estimation via Web3.js starting with version 2.0.5 of the Metamask wallet. This problem affects users who have successfully used the code for a long time, like you.
To mitigate this problem, we recommend updating the contract deployment scenario to use a second gas cost estimation method, for example:
- Ethers.js: a popular library for interacting with the Ethereum blockchain, which provides accurate and reliable gas estimation.
- ContractKit: an open source library for creating smart contracts on the Ethereum network, offering robust gas valuation functions.
Mitigation Strategy
To minimize the impact of this error, you can:
- Update your code to use the second method of estimating the cost of gas.
- Track real-time gas consumption estimates using Ethers.js or ContractKit.
- Be careful when deploying contracts on the Ethereum network and verify the accuracy of gas estimates before deployment.
Next Steps
If you have any additional problems related to this error, please contact our support team for help or advice. We strive to provide accurate information and help users like you navigate the complexities of developing smart contracts on the Ethereum blockchain.
By taking proactive steps to address this issue, you can provide a more user-friendly user interface and reduce the likelihood of gas estimation errors in Metamask.
No Comments