Good question!
A hard fork doesn't necessarily mean the functionality wouldn't be backwards compatible. It means that users of the blockchain need to upgrade their clients, and that clients with the old version are no longer compatible with the blockchain. I would word it like this: client compatibility and function compatibility are different things.
Yes, you can still use the legacy transaction model, but it will not benefit from the newest changes. Here's some more info: https://eips.ethereum.org/EIPS/eip-1559#backwards-compatibility . You just can't use the legacy clients (they won't get synchronized).
Granted, it's a bit tricky to try to figure out what does it exactly mean that the EIP is backwards compatible. All the places just say "yes it's compatible, it just won't benefit from the new system". So I'm not 100% clear on that.
Let's quickly understand how the fee is changed in EIP-1159.
- Base Fee: Base fee is determined by the network itself.
- Max Priority Fee: Optional. Determined by the user and paid directly to the miner.
- Max Fee Per Gas: This is the absolute maximum fee you want to pay per unit of gas.
In the EIP-1159 transaction; we supply maxFeePerGas
and maxPriorityFeePerGas
. The base fee is automatically calculated by the network.
Now the base fee can increase/decrease but we have already supplied the max fee we want to pay in maxFeePerGas
. So if baseFee
increases in the next block, the priority fee can be adjusted to make sure the total fee never crosses the max fee.
Base Fee + Priority Fee <= Max Fee
Now about calculating the fee;
we need to get the base fee from the blockchain node and we can then decide how much max fee we want to make. Ideally, if you want your tx to be valid even after 6 blocks (assuming the base Fee increases to a maximum per block); you can use given formulae to calculate the max fee.
Max Fee = (2 * base fee) + Priority fee
So in terms of how do we get each field:
baseFee = await (web3.eth.getBlock("pending")).baseFeePerGas
priorityFee = choose yourself
MaxFee = (2 * baseFee) + priorityFee
Best Answer
First, there is a
Base Fee
which is the minimum fee a transaction must pay to be a valid transaction. The Base Fee changes per block, depending on how full the previous block is. The Base Fee is burned so the block producer (miner/validator) does not receive any of it.The
Priority Fee
is what a transaction would pay a block producer when the transaction is included in a block. TheMax Priority Fee
is a maximum because the block producer may be paid less. One way this can happen is by specifying aMax Gas Fee
(a.k.a. Max Fee Per Gas), which is the total fee a transaction is willing to pay.For example, if a transaction specifies
Max Gas Fee = 9
andMax Priority Fee = 3
, ifBase Fee = 8
, then1
would be paid to the block producer (Max Gas Fee - Base Fee), and8
would be burned (Base Fee). Such a transaction is only valid in a block whose Base Fee reaches 9 or less.All the fees are per unit of gas, as EIP-1559 specifies:
base_fee_per_gas
,max_priority_fee_per_gas
,max_fee_per_gas
.