TECHNICAL PRIMER · NO. 01

Gas Fees, Demystified

Why every transaction costs what it costs — and what you can actually do about it.

10 MIN READ
CONTENTS
  1. 01What gas actually is
  2. 02EIP-1559: how Ethereum prices gas today
  3. 03What makes gas spike
  4. 04The day/week pattern
  5. 05Layer 2s and why they're cheaper
  6. 06The math of optimization
  7. 07Why transactions fail (and you still pay)
  8. 08Glossary

What gas actually is

Gas is a unit of computational work. Not a currency. Not a fee in itself. Every operation the Ethereum Virtual Machine executes — adding two numbers, reading from storage, writing to state — costs a fixed number of gas units. Sending ETH from one address to another requires exactly 21,000 gas. Always. No variance.

What varies is the price you pay per unit of gas, denominated in gwei (one gwei = 10⁻⁹ ETH). Your actual cost is the product of two things: gas used × gas price. If you send ETH when gas is 20 gwei, you pay 21,000 × 20 × 10⁻⁹ ETH = 0.00042 ETH. If gas is 100 gwei, that same transfer costs 0.0021 ETH.

Simple ETH transfer: 21,000 gas · Token swap: 100k–300k gas · Complex DeFi op: 1,000,000+ gas

Operations scale with complexity. A simple ETH transfer burns 21,000 gas. A token swap on a DEX typically uses 100,000 to 300,000 gas, depending on how many internal calls the contract makes. A complex DeFi operation — routing through multiple liquidity pools, checking oracle prices, updating positions — can exceed 1,000,000 gas. Every instruction the EVM executes has a cost defined in the Yellow Paper.

This distinction matters because gas is not a market for transactions — it is a market for computation. You are paying for CPU cycles on a decentralized computer. The analogy to cloud compute pricing is not accidental.

EIP-1559: how Ethereum prices gas today

Before August 2021, Ethereum used a first-price auction. You named your gas price, miners picked the highest bids, and during congestion you were forced into a guessing game: bid too low and your transaction sat in the mempool indefinitely; bid too high and you overpaid massively.

EIP-1559, activated in the London hard fork, replaced this with an algorithmic mechanism. Every block now has a base fee — the minimum price any transaction in that block must pay. This base fee is not paid to validators; it is burned, removing ETH from circulation permanently. You also pay an optional priority fee (the "tip") directly to the validator who includes your transaction.

Block fullness → base fee adjustment
0% 25% 50% TARGET 75% 100% LOW HIGH base fee falls base fee rises
Base fee rises when blocks are full, falls when they are empty. Rate: ±12.5% per block maximum.

The base fee adjusts every block based on how full the previous block was. Target block size is 15 million gas. If a block is fuller than 50% target, the next block's base fee increases by up to 12.5%. If it is below target, base fee decreases. This creates a predictable, responsive pricing signal — and it killed the wild overbidding wars of the pre-London era.

In practice, you set a maxFeePerGas (the most you are willing to pay per gas unit in total) and a maxPriorityFeePerGas (your tip to the validator). You pay base fee + tip, but never more than your maxFeePerGas. Any difference between your max and the actual cost is refunded.

What makes gas spike

Gas price follows demand. When more people want block space simultaneously, the base fee climbs. These are the most common causes:

01
NFT mints with limited supply
When a highly anticipated collection drops with a hard cap, thousands of wallets submit transactions simultaneously. The mempool floods, base fee rockets, and the mint resolves in seconds — but at 10-50x normal gas.
02
Token launches and bridge activity
New token launches bring speculative volume. Bridges moving assets between chains — especially during market moves — generate sustained high-gas periods as traders position.
03
Liquidations during market crashes
Lending protocols liquidate undercollateralized positions automatically. During sharp price drops, hundreds of positions become eligible simultaneously, triggering cascading transactions from liquidation bots.
04
MEV bot activity
Maximal Extractable Value bots front-run, back-run, and sandwich profitable transactions. During high-volatility periods, MEV bots compete aggressively, bidding up priority fees and crowding the mempool.
05
Popular dApp congestion
A viral game, a high-profile airdrop claim, a governance vote deadline — any event that drives simultaneous user action compresses block space and sends gas upward.

The day/week pattern

Gas prices are not random noise. They track global human activity — specifically, when traders in North America, Europe, and Asia are awake and transacting simultaneously.

The cheapest windows are structurally predictable: weekend nights UTC, and particularly Sunday mornings before US East Coast wakes up. Between roughly 00:00 and 08:00 UTC on weekends, average mainnet gas is 30-60% lower than weekday afternoon peaks.

The data below reflects averaged ETH mainnet base fees over 90 days. Each cell represents one hour-of-week. Darker orange means more expensive. The cheapest hours — consistently — are Sunday 02:00–07:00 UTC.

Layer 2s and why they are cheaper

Ethereum mainnet is deliberately constrained. Block space is scarce by design — that scarcity is what makes it secure and decentralized. Layer 2 networks solve the cost problem by moving execution off mainnet while inheriting its security.

Optimistic rollups (Arbitrum, Optimism) batch hundreds of transactions together and post compressed data to mainnet. They assume transactions are valid unless challenged. ZK-rollups (Base uses a ZK stack; zkSync, StarkNet) use cryptographic validity proofs to verify batches without re-executing them on mainnet.

The cost difference is stark. A token swap on Ethereum mainnet at 30 gwei costs roughly $2–8 depending on ETH price. The identical operation on Arbitrum or Base costs $0.01–0.05. The reason: you are sharing mainnet calldata costs across thousands of bundled transactions.

EIP-4844, activated in March 2024 in the Dencun upgrade, introduced blob transactions — a new transaction type for rollups that carries data outside the normal calldata field, at dramatically lower cost. L2 fees dropped another 10-100x after Dencun. A swap on Base today typically costs under $0.01.

The math of optimization

Concrete numbers. Assumptions: 10 transactions per month, averaging 150,000 gas each (a typical DEX swap). ETH price: $3,000.

The peak-to-off-peak gap alone is 77%. The mainnet-to-L2 gap is 99.9%. These are not edge cases — they are the everyday reality of anyone doing volume.

Why transactions fail — and you still pay

A failed transaction is not free. This surprises people, but it follows directly from how the EVM works.

When you submit a transaction, validators execute it. If the execution reaches a REVERT opcode — because a condition failed, a slippage check didn't pass, you tried to transfer more tokens than you own, or a contract assertion fired — the EVM unwinds all state changes. Your transaction had no effect. The chain looks the same as before.

But the validator did work. They executed every instruction up to the revert. They consumed block space. The base fee was burned. The work was real, even if the outcome was undone. Charging gas for failed transactions is not punitive — it is the only design that prevents denial-of-service attacks where anyone could flood the network with complex transactions at zero cost.

Common causes of reverts: insufficient slippage tolerance on DEX swaps (price moved between submission and execution), interacting with a contract that has already reached a participation cap, insufficient token allowance, or a race condition where another transaction changed state that your transaction depended on.

// NOTE
To minimize revert risk: set slippage tolerance to match current volatility, check token allowances before submission, and avoid submitting at exactly the last block of an event (like a mint).

Glossary