Gas Mechanics & EIP-1559
EIP-1559 (London fork, August 2021) fundamentally changed Ethereum's fee mechanism. Understanding baseFee, priorityFee, and fee burning is essential for building reliable dApp transaction UX.
EIP-1559 Fee Model
Pre-EIP-1559 (legacy): You bid a gasPrice, miners take it all.
Post-EIP-1559: Dynamic baseFee + miner tip split:
baseFee:
- Protocol-set minimum per-gas price
- Burned forever (reduces ETH supply — 'ultrasound money')
- Adjusts ±12.5% per block based on usage vs 15M gas target
- Full block (30M gas) → baseFee increases 12.5% next block
- Empty block → baseFee decreases 12.5%
- baseFee is always the same for all txs in a block
maxPriorityFeePerGas (tip):
- Goes to the validator
- Incentivizes inclusion in the next block
- ~1-2 gwei is typical; higher for urgent transactions
maxFeePerGas:
- Your absolute maximum (baseFee + tip must not exceed this)
- Refund: (maxFeePerGas - baseFee - tip) × gasUsed returned to you
- Safety: if baseFee surges, your tx waits rather than overpaying
Effective gas price = baseFee + min(tip, maxFeePerGas - baseFee)Common Mistakes
- Setting maxFeePerGas = maxPriorityFeePerGas — if baseFee > 0 (always true), this makes the effective tip = 0, meaning validators have no incentive to include your tx
- Not accounting for baseFee spikes — during NFT mints or popular events, baseFee can spike 10-100x in minutes. Set maxFeePerGas at least 2-3x current baseFee for urgent txs
- Using legacy transactions in new projects — always use Type 2 (EIP-1559) transactions for better fee predictability and UX. Legacy transactions overpay when baseFee is low.
Tip
Tip
Practice Gas Mechanics EIP1559 in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.
Once deployed, smart contracts are immutable — code is law
Practice Task
Note
Practice Task — (1) Write a working example of Gas Mechanics EIP1559 from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.
Quick Quiz
Common Mistake
Warning
A common mistake with Gas Mechanics EIP1559 is skipping edge case testing — empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready web3 code.
Key Takeaways
- EIP-1559 (London fork, August 2021) fundamentally changed Ethereum's fee mechanism.
- Setting maxFeePerGas = maxPriorityFeePerGas — if baseFee > 0 (always true), this makes the effective tip = 0, meaning validators have no incentive to include your tx
- Not accounting for baseFee spikes — during NFT mints or popular events, baseFee can spike 10-100x in minutes. Set maxFeePerGas at least 2-3x current baseFee for urgent txs
- Using legacy transactions in new projects — always use Type 2 (EIP-1559) transactions for better fee predictability and UX. Legacy transactions overpay when baseFee is low.