Understanding Ethereum’s Maximum Gas Fee
In Ethereum, the maxFeePerGas
parameter allows miners to set a maximum fee per unit of gas for transactions. However, it is important to understand how this value affects the actual gas cost of your transaction.
Maximum Gas Fee: Not Per Unit of Gas
The term `maxFeePerGas'' is often misinterpreted as
per unit of gas''. This means that the maximum fee will be charged regardless of the number of units in the gas pool. This is not a direct conversion to per unit fees.
Inserting the Maximum Gas Fee into a Gas Pool: Formula
To calculate the actual gas cost, you need to consider two factors:
- MaxFeePerGas: The maximum fee per transaction.
- TotalGasUnitsRequired
: The total number of gas units required for your transaction.
Using a simple formula, let's calculate the actual cost of gas:
Actual cost of gas = MaxFeePerGas + (MaxFeePerGas x TotalGasUnitsRequired)
Example: 10,000 gas units required
Let's say you want to pay up to 50 gwei per gas unit. To calculate the actual gas price:
Actual gas cost = 50gwei + (50gwei x 10,000) = 50gwei + 500gwei = 550gwei
Practical application
In your example, if you send a transaction that requires 10,000 units of gas and want to pay up to 50 gwei per unit, the value ofmaxFeePerGas'' would be:
maxFeePerGas = 50gwei + (50gwei x 10^-9)
This is equivalent to paying 550 gwei for 10,000 gas units.
Conclusion
In short: when setting `maxFeePerGas'', you should not confuse it with
`per unit of gas.” It is important to understand that the maximum fee will be charged regardless of the number of units in the gas pool. When calculating the actual gas price, use the formula above and take into account the total number of gas units required for your transaction.
I hope this explanation helps clear things up!