Looking at the fee structure of the EIP – 1559, I noticed we have such terms as maxPriorityFeePerGas
and maxFeePerGas.
I think maxPriorityFeePerGas
is basically tip you pay the miner and maxFeePerGas
is the maximum amount you are wiling to pay.
My question is, where does PerGas
come from? Aren't they really maxPriorityFeePerGas
and maxFeePerGas
?
Best Answer
Gas is the measure of computation required to execute your transaction, depending on what functions your contract uses the gas used changes. This is analogous to the transaction bytes size in Bitcoin transactions.
The fees you set are how much gwei you are willing to pay for each gas unit, that's why it's
PerGas
. It's analogous to thesatoshi/vbytes
in Bitcoin transactions.So for example, let's say my contract has a function that spends 130k gas and I set the
maxFeePerGas
to50
, then I'll be paying maximum130000 * 50 = 6500000 gwei = 0.0065 ether
.And you're correct about
maxPriorityFeePerGas
andmaxFeePerGas
, but just to make it crystal clear:maxPriorityFeePerGas
is a tip you'll be paying to the miner so that your transaction is processed before others.maxFeePerGas
is the maximum you'll be paying in total asbaseFeePerGas + PriorityFeePerGas
, wherebaseFeePerGas
is calculated by the protocol.You always pay the
baseFeePerGas
, if that's belowmaxFeePerGas
the rest will be paid to the miner ifmaxPriorityFeePerGas
is above zero. The paid priority fee can be lower depending on the maximum fee set.E.g.
You'll pay only 20 as priority fee because that's what's left between maximum and base fees.