Ethereum Gas Optimization

Gas is Ethereum’s fundamental resource metering mechanism — the unit that quantifies computational work and storage consumption on the network, paying validators for transaction processing. Gas fees have been the primary friction point in Ethereum’s user experience since the network launched, occasionally surging to hundreds of dollars per transaction during peak NFT mints or DeFi activity. Understanding how gas works, when fees are lowest, and how Layer 2 networks fundamentally change the economics is essential knowledge for any active Ethereum user.


How Ethereum Gas Works

The following sections cover this in detail.

The EIP-1559 Fee Structure (Post-August 2021)

Prior to August 2021, Ethereum used a simple first-price auction: users bid a “gas price” (in gwei — 1 gwei = 0.000000001 ETH), and miners included transactions in the order of highest gas price bid. This created volatile fees, poor UX (overpaying was common), and all fees going to miners.

EIP-1559 (implemented in the London hard fork, August 2021) replaced this with a two-component fee structure:

1. Base Fee:

  • A network-set minimum price required to get a transaction included in the current block
  • Calculated algorithmically based on network congestion: if the previous block was >50% full, the base fee increases; if <50% full, it decreases
  • Maximum change per block: ±12.5%
  • Burned (not paid to miners/validators): The base fee is permanently destroyed, reducing ETH supply
  • The base fee adjustment mechanism creates a largely predictable fee trajectory — base fee cannot spike 10× in a single block

2. Priority Fee (Tip):

  • An optional additional payment to the block proposer (validator in PoS; previously miner in PoW)
  • Incentivizes validators to include your transaction rather than waiting
  • During normal market conditions, 1–2 gwei tip is sufficient
  • During extreme congestion events (NFT mints, major protocol launches), effective priority fees can reach 100–500+ gwei

Gas limit:

  • Each transaction specifies a gas limit — the maximum gas units the transaction can consume
  • If a transaction runs out of gas before completing, it reverts (fails) but the gas already consumed is still charged
  • Standard ETH transfer: 21,000 gas
  • Simple ERC-20 token transfer: ~45,000–65,000 gas
  • Complex DeFi swap (Uniswap V3): ~125,000–250,000 gas
  • NFT mint: ~50,000–200,000+ gas depending on contract complexity

The ETH cost formula:

Transaction cost = (Base Fee + Priority Fee) × Gas Used

Example: Sending ETH at 20 gwei base fee + 1 gwei priority fee × 21,000 gas = 441,000 gwei = 0.000441 ETH


Gas Units and Gwei

Wei: The smallest unit of ETH (10^-18 ETH). Named after Wei Dai, the cryptographer who proposed B-money.

Gwei (gigawei): 10^9 wei = 0.000000001 ETH. The standard unit for expressing gas prices.

Common reference points:

  • 1 gwei: Near-zero fee environment (late nights, weekends during bear markets)
  • 10–20 gwei: Normal moderate activity
  • 50–100 gwei: High activity / active market
  • 200–500 gwei: Peak congestion (major NFT mint, market crash)
  • 1,000+ gwei: Extreme rarity; seen during the most severe demand spikes (BAYC mint, peak CryptoKitties 2017 before EIP-1559)

Gas Monitoring Tools

The following sections cover this in detail.

Etherscan Gas Tracker

URL: etherscan.io/gastracker

The Etherscan Gas Tracker provides real-time base fee, recommended priority fee tiers (Low/Standard/High/Rapid), and a 14-day historical gas price chart. The three tiers correspond to different confirmation time targets:

  • Low: Accept any delay for the best price
  • Standard: ~1–3 block confirmation target
  • Fast: Immediate next-block inclusion

Blocknative Gas Estimator

Blocknative’s gas estimator uses mempool analysis (tracking transactions waiting to be included) to provide more accurate real-time fee recommendations. It can predict how congestion will evolve over the next few minutes — useful for timing large transactions.

ETH Gas.watch (and similar)

Aggregates multiple gas data sources and provides alert subscriptions — you can set a “target gwei” and receive a notification when base fee drops below your threshold.

DeFi applications built-in gas estimation

Modern wallets (MetaMask, Rabby) and DeFi interfaces (Uniswap, Aave) provide built-in gas estimators that recommend fees based on current network conditions. MetaMask since 2022 uses EIP-1559 fee management natively, allowing users to select between “Low,” “Market,” and “Aggressive” confirmation speed tiers.


When to Transact: Gas Timing

The following sections cover this in detail.

Weekly Patterns

Ethereum gas fees follow a strong weekly pattern driven by US business hours and Asian trading sessions:

Low-fee windows:

  • Saturday and Sunday UTC mornings (roughly 0:00–12:00 UTC Saturday/Sunday)
  • US markets closed; Asian activity lower; DeFi activity reduced
  • Base fees can be 40–70% lower than peak weekday levels

High-fee windows:

  • Monday through Friday 12:00–22:00 UTC (8 AM–6 PM US Eastern; overlapping with US and European business hours)
  • Major protocol launches, token launches, and NFT mints often occur on weekdays during peak hours when maximum attention is available — these explicitly avoid the optimal gas timing

Quantified example: A transaction that costs 50 gwei on Tuesday at 14:00 UTC may cost only 8–15 gwei on Saturday at 06:00 UTC — a 70–85% cost reduction for the exact same operation.

Event-Driven Spikes

The most important gas timing consideration for power users is avoiding predictable spike events:

  • Protocol token launches / IDOs: Opening moments of new token claims or purchases
  • NFT mint events: Especially for collections with large waitlists; the mint opening causes thousands of simultaneous transactions
  • Market crash events: Cascading liquidations in DeFi protocols cause massive transaction volume spikes
  • Federal Reserve announcements / CPI data: Macro events affecting crypto prices create trading activity spikes

Layer 2 Solutions: 90%+ Gas Reduction

The most dramatic gas optimization is simply using Layer 2 networks:

Network Avg. Gas Cost (ETH transfer equivalent) Notes
Ethereum L1 $1–$50+ during congestion Base fee dependent
Arbitrum One $0.01–$0.10 Optimistic rollup (OP stack fork)
Optimism $0.01–$0.10 OP Stack optimistic rollup
Base $0.005–$0.05 Coinbase-built, OP Stack
Polygon PoS $0.001–$0.01 Sidechain (not a true L2)
zkSync Era $0.01–$0.15 ZK rollup
Starknet $0.005–$0.10 ZK rollup (STARK proofs)

Post-Dencun (EIP-4844) fees: The March 2024 Dencun upgrade dramatically reduced L2 costs further (see below). Most L2 transactions post-Dencun cost $0.001–$0.05 — effectively free for most users.


EIP-4844: Blob Transactions and Proto-Danksharding

The Dencun upgrade (March 13, 2024) implemented EIP-4844 — the most significant Ethereum gas cost reduction in the network’s history, primarily benefiting Layer 2 networks.

The Problem Being Solved

Layer 2 networks must periodically publish their compressed transaction data back to Ethereum L1 as “calldata” — the primary security mechanism that allows anyone to reconstruct L2 state from Ethereum itself. Before EIP-4844, this calldata was stored in Ethereum’s permanent state (the most expensive type of storage), and the cost was passed to L2 users as part of their transaction fees.

Blob Transactions

EIP-4844 creates a new transaction type — “blob-carrying transactions” — that attach 128 KB data “blobs” alongside regular transaction data with three critical differences:

  1. Blobs are NOT stored permanently in Ethereum state. They are stored for approximately 18 days and then pruned from the network.
  2. Blobs have a separate fee market with their own base fee mechanism — initially targeting 3 blobs per block.
  3. Blobs are exponentially cheaper than equivalent calldata — typically 10–100× cheaper for the same amount of data.

Effect on L2 costs: L2 networks (Arbitrum, Optimism, Base, zkSync, Starknet) immediately switched to using blob transactions for their L1 settlement data. The result:

  • Arbitrum and Optimism fees dropped approximately 90% immediately on the day of the Dencun upgrade
  • Base fees dropped to fractions of a cent for most transactions
  • The L2 fee reduction was larger than any previous Ethereum upgrade’s impact on L2 economics

Security note: Blob data remains available for 18 days — sufficient time for anyone to challenge fraudulent state transitions in optimistic rollups (which have a 7-day fraud challenge window) and for full nodes to sync. The temporary storage does not compromise security.


Developer-Level Gas Optimization

For Solidity developers writing smart contracts, gas optimization is a distinct skill set:

Storage Operations

SSTORE (write to storage): ~20,000 gas for updating an unset slot; ~5,000 gas to update an already-set slot

  • Pack multiple variables into a single storage slot: Solidity stores variables in 32-byte slots; packing uint128 a; uint128 b; together uses 1 slot vs. 2 slots for uint256 a; uint256 b;
  • Use memory vs storage keywords correctly: Reading from memory is ~3 gas; reading from storage is 100–2,100 gas; always cache storage reads in local variables if used multiple times

Computation Optimization

  • unchecked{} blocks: Turn off overflow/underflow checking inside loops when you know values are safe. Saves ~30–50 gas per arithmetic operation — material in loops
  • Custom errors vs. require strings: revert CustomError() is cheaper than require(condition, "error message") — string storage costs gas
  • Bit shifting over multiplication/division by powers of 2: x >> 1 vs x / 2 — marginally cheaper, but optimization opportunities accumulate
  • Avoid redundant condition checks: If you’ve already checked a condition, don’t check it again in a called sub-function

Calldata Optimization

  • Use calldata instead of memory for function parameters that are read-only: calldata is cheaper to access for external functions
  • Minimize bytes in calldata: Each byte costs 4 gas if zero, 16 gas if non-zero; function selectors and addresses can be encoded compactly through libraries like OpenZeppelin’s ShortStrings
  • EIP-2028 (2019): Reduced calldata cost from 68 gas/non-zero byte to 16 gas/non-zero byte — historical optimization that already happened at protocol level

Related Terms


Sources

Buterin, V., Conner, E., Dudley, R., Slipper, M., Norden, I., & Bakhta, A. (2019). EIP-1559: Fee Market Change for ETH 1.0 Chain. Ethereum Improvement Proposals, EIP-1559, April 2019.

Dankrad Feist, Vitalik Buterin, et al. (2022). EIP-4844: Shard Blob Transactions. Ethereum Improvement Proposals, EIP-4844, February 2022.

Wood, G. (2014, updated 2024). Ethereum Yellow Paper: A Formal Specification of Ethereum, a Programmable Blockchain. ethereum.github.io/yellowpaper/paper.pdf.

Roughgarden, T. (2021). Transaction Fee Mechanism Design for the Ethereum Blockchain: An Economic Analysis of EIP-1559. arXiv:2012.00854, published January 2021.

Helms, K. (2024). Ethereum Dencun Upgrade Reduces Layer 2 Transaction Fees by Up to 99%. Bitcoin.com News, March 2024.