When developing, testing, trading, or purchasing, there are always a slew of gas options and noise that pops up on Metamask. Recently, we faced a bug that was suggesting a gas fee of almost $15,000 to purchase a 1ETH NFT. That’s crazy!
The bug turned out to be a combination of error handling and environmental issues, but we can save the technical specs on that for another day. What we’ll cover is how the recommended gas limit is calculated and what the different UI sections on Metamask represent.
For every transaction that is handled by Metamask, there are three fields that are calculated:
The Gas Limit is the maximum amount of gas that you are willing to pay for the transaction to be verified and added to the ledger.
The Gas Price is the amount you want to pay per unit of gas to the miner. This one is a bit more nuanced (how tf are you going to know this?).
The gas limit is almost arbitrary, as Ethereum will only take the amount necessary to complete the transaction, and refund the remainder. The gas price is what matters, and it is set in GWEI- it is easier to say that the gas unit costs 1 GWEI vs 0.000000001 ETH, although the latter is becoming easier to understand as we further interact with Ethereum.
So, your entire transaction cost is the (Gas Limit specified - gas units used by the EVM) * Gas Price specified. In the future, I believe that a lot of this will be masked away, like the cost of gas when we purchase from a gas station. In the same way that we choose the gas price we are willing to pay by selecting a gas station, we will choose a provider.