Gas and Ethereum Fees
Gas meters EVM resource usage, while fees price scarce block space and priority.
Gas explains failed transaction costs, expensive storage, denial-of-service resistance, and EIP-1559 fee mechanics.
The Intuition
Gas is a fuel meter. Each operation consumes fuel. If execution runs out of fuel, state changes revert, but the consumed fuel is gone.
See it concretely
If a machine starts working but fails halfway, the electricity was still used. Ethereum charges for work attempted, not only successful outcomes.
Tempting — but wrong
The precise version
Each EVM opcode has a gas cost. Users set a gas limit and fee parameters. Under EIP-1559, each block has a base fee that is burned and users may add a priority fee for block producers. The base fee adjusts according to block gas usage relative to the target.
maxCost = gasLimit \times maxFeePerGasCheck your understanding
Why do failed transactions still cost gas?
Click to reveal answer
What does EIP-1559 burn?
Click to reveal answer
- Distinguish gas units from ETH.
- Explain gas limit, base fee, max fee, and priority fee.
- Explain why storage is expensive.
- Explain why out-of-gas reverts state but not spent gas.
What happens when a transaction runs out of gas?