MetaMask / MetaMask/metamask-extension

Incorrect gas estimation when account has not enough ETH

Open
#10,276 8 comments 10 reactions 1 assignee View on GitHub

@Gudahtt is already working on this.

Since Feb 2, 2021.

area-gas area-transactions needs-design team-confirmations-planning type-enhancement ux-enhancement
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**
![image](https://user-images.githubusercontent.com/439188/105623757-4d65f980-5e2d-11eb-9ce8-ba5463d42edb.png)

**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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.