Skill 5.1.2
Calculate transaction fees under EIP-1559
Key Concepts
Since the London upgrade (August 2021), each block has a protocol-set base fee per gas. The base fee is burned. Each block targets using half of the block gas limit; if a block uses more than the target, the next base fee rises by up to 12.5%, and if it uses less, the base fee falls by up to 12.5%.
A type 2 transaction sets maxPriorityFeePerGas, the tip per gas for the block proposer, and maxFeePerGas, the most it will pay per gas in total. The effective gas price is the base fee plus the priority fee, capped at the max fee: min(maxFeePerGas, baseFee + maxPriorityFeePerGas). The fee paid is gas used × effective gas price; the difference between the max fee and the effective price is never charged.
Example: a transfer uses 21,000 gas when the base fee is 12 gwei and the tip is 2 gwei, with a max fee of 30 gwei. The effective price is 14 gwei, so the fee is 21,000 × 14 = 294,000 gwei = 0.000294 ETH, of which 252,000 gwei is burned and 42,000 gwei goes to the proposer. Legacy (type 0) transactions use a single gasPrice, treated as both the max fee and the max priority fee.