Describe the bug
When a dapp sends a transaction, and specifies the gasPrice but not the gas, we will sometimes set the gas property to the block gas limit internally. I believe this happens when the total cost of the transaction (considering the cost of gas as well, using the estimated gas usage and the suggested gas price) exceeds the users current balance.
This inflated gas limit is then shown on the transaction confirmation screen. The block gas limit is much higher than most transactions require, so this results in transaction confirmations with huge gas costs.
This is caused by our use of eth_estimateGas, which fails if a gasPrice is given and the transaction exceeds the user's current balance.
Steps to reproduce (REQUIRED)
- Switch to an account with no balance
- Navigate to a dapp and connect the empty account
- Open Dev Tools, and run this in the dev console:
await window.ethereum.request({ method: 'eth_sendTransaction', params: [{ from: window.ethereum.selectedAddress, gasPrice: '0x1000' }] })
- See that the gas limit on the confirmation screen is very high
Expected behavior
The suggested gas price should not affect the suggested gas limit. We should estimate the gas usage irrespective of the gas price suggested. If the user has insufficient funds, we have a warning message for that already on the confirmation screen.
Describe the bug
When a dapp sends a transaction, and specifies the
gasPricebut not thegas, we will sometimes set thegasproperty to the block gas limit internally. I believe this happens when the total cost of the transaction (considering the cost of gas as well, using the estimated gas usage and the suggested gas price) exceeds the users current balance.This inflated gas limit is then shown on the transaction confirmation screen. The block gas limit is much higher than most transactions require, so this results in transaction confirmations with huge gas costs.
This is caused by our use of
eth_estimateGas, which fails if agasPriceis given and the transaction exceeds the user's current balance.Steps to reproduce (REQUIRED)
Expected behavior
The suggested gas price should not affect the suggested gas limit. We should estimate the gas usage irrespective of the gas price suggested. If the user has insufficient funds, we have a warning message for that already on the confirmation screen.