MetaMask / MetaMask/metamask-extension
Incorrect gas estimation when account has not enough ETH
@Gudahtt is already working on this.
Since Feb 2, 2021.
- Dominant language
- TypeScript
- Stars
- 13.2k
- Forks
- 5.6k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 451
Description
Gas fees are too high when tx has error. It showed correct gas fees before
**Steps to reproduce (REQUIRED)**
Steps to reproduce the behavior, libraries used with version number, and/or any setup information to easily reproduce:
1. Go to https://etherscan.io/address/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2#writeContract (wrapped ether)
2. Connect to web3 using metamask
3. Scroll down to "deposit" function
4. Try to execute tx with small ETH amount (0.001) - ETH amount should be less than in account - everything's ok. Gas estimation is ok (about 65k)
5. Try to execute tx with ETH amount you don't own - metamask will show correct error "insufficient funds", but gas estimation is like 11M and initial tx confirm page shows huge transaction fee (currently about 700$)
Also, note, this is not specific to this tx, but this happens for every tx without gas provided.
**Expected behavior**
Gas estimation should work correctly and gas fee should be the same as in correct tx.
**Screenshots**

**Browser details (please complete the following information):**
- OS: Linux, Mac OS
- Browser: Chrome, Firefox
- MetaMask Version: 9.0.3
** Workaround **
It is possible to calculate gas and send tx with correct gas to web3. This way everything works like it was before
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.