blockmindset
Lesson 3 of 512 min

Gas and Ethereum Fees

Gas meters EVM resource usage, while fees price scarce block space and priority.

Why this matters

Gas explains failed transaction costs, expensive storage, denial-of-service resistance, and EIP-1559 fee mechanics.

1

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.

2

See it concretely

Concrete example

If a machine starts working but fails halfway, the electricity was still used. Ethereum charges for work attempted, not only successful outcomes.

3

Tempting — but wrong

4

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 maxFeePerGas

Check your understanding

Why do failed transactions still cost gas?

Click to reveal answer

What does EIP-1559 burn?

Click to reveal answer

Before moving on
  • 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.
?Checkpoint

What happens when a transaction runs out of gas?