Ethereum: maxFeePerGas, is it per unit of gas? or by the gas that tx needs?

Understanding Ethereum Max Fee Per Gas

In Ethereum, the maxFeePerGas parameter allows miners to set a maximum fee per gas unit for transactions. However, it’s essential to understand how this value affects the actual gas cost of your transaction.

Max Fee Per Gas: Not per Gas Unit

The term “maxFeePerGas” is often misinterpreted as “per gas unit.” It 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 fees per unit.

Feeding Max Fee Per Gas into Gas Pool: A 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 gas cost:

Actual Gas Cost = MaxFeePerGas + (MaxFeePerGas x TotalGasUnitsRequired)

Example: 10,000 Gas Units Required

Suppose you want to pay up to 50gwei per gas unit. To calculate the actual gas cost:

Actual Gas Cost = 50gwei + (50gwei x 10,000) = 50gwei + 500gwei = 550gwei

Putting it into Practice

Ethereum: maxFeePerGas, is this per gas unit? or per the gas the tx needs?

In your example, if you send a transaction that requires 10,000 gas units and want to pay up to 50gwei per unit, the maxFeePerGas value would be:

maxFeePerGas = 50gwei + (50gwei x 10^-9)

This is equivalent to paying 550gwei for 10,000 gas units.

Conclusion

To summarize: when setting maxFeePerGas, you should not confuse it with “per gas unit.” It’s essential to understand that the maximum fee will be charged regardless of the number of units in the gas pool. When calculating the actual gas cost, use the formula above and consider the total number of gas units required for your transaction.

I hope this explanation helps clarify things!

Bitcoin Accepting Transactions Insufficient Fees

Leave a Reply

Your email address will not be published. Required fields are marked *