Back to Blog

How Ethereum Gas Fees Work: Gwei, EIP-1559, and Saving Money on Transactions

Onchain 101DeFi

Understand what you're actually paying for when you send ETH, swap tokens, or mint NFTs. Learn how gas units, Gwei, and EIP-1559 determine costs—and practical ways to pay less.

Summarize this post with

The first time I tried to mint an NFT during a hyped drop, the network was so congested that my $15 transaction ended up costing $180 in gas fees. The mint failed anyway—I didn't set my gas limit high enough. I paid for computation that did nothing.

If you've ever watched your wallet estimate a fee, wondered why a simple token swap costs more than transferring ETH, or lost money to a failed transaction, this guide is for you. Gas fees aren't arbitrary—they follow predictable rules. Once you understand those rules, you can time transactions better, avoid overpaying, and stop losing money to avoidable mistakes.

We'll cover what gas actually measures, how EIP-1559 changed fee mechanics, why some actions cost more than others, and how Layer 2 networks like Base cut costs by 95% or more. By the end, you'll read block explorer fee breakdowns with confidence and know exactly how to pay less without getting stuck in the mempool.

Why Gas Fees Exist

Every action on Ethereum requires someone to process it. Validators run specialized hardware, stake 32 ETH as collateral, and verify every transaction across the network. Gas fees are how they get paid for this work.

Without fees, nothing would stop someone from flooding Ethereum with millions of spam transactions. Gas creates an economic barrier: every operation costs money, making attacks expensive. This keeps the network usable for everyone.

Fees also manage limited block space. Ethereum processes roughly 15-30 transactions per second. When more people want to transact than the network can handle, fees rise until demand matches capacity. It's a live auction, running every 12 seconds when a new block gets produced.

The money goes directly to validators—not to wallet apps, not to Ethereum Foundation, not to Vitalik. It compensates the people actually running the infrastructure. Since the 2022 merge to proof-of-stake, validators earn fees on top of staking rewards for securing the network.

What Gas Actually Measures

Gas measures computational work, not money. Think of it like electricity usage: your appliances consume kilowatt-hours based on how much power they draw, and your bill depends on the price per kilowatt-hour. Gas works the same way—operations consume gas units, and your cost depends on the price per unit.

Every Ethereum operation has a fixed gas cost:

  • Simple ETH transfer: 21,000 gas (this is hardcoded in the protocol)
  • ERC-20 token transfer: ~50,000-65,000 gas
  • Uniswap swap: ~100,000-250,000 gas
  • NFT mint: ~150,000-500,000 gas depending on contract complexity
  • Smart contract deployment: 1,000,000+ gas

These numbers don't change with network conditions. What changes is how much you pay per unit.

Gwei: The Pricing Unit

Gas prices are denominated in Gwei, a tiny fraction of ETH:

  • 1 ETH = 1,000,000,000 Gwei (one billion)
  • 1 Gwei = 0.000000001 ETH

When someone says "gas is 20 Gwei right now," they mean each unit of gas costs 0.00000002 ETH. Multiply that by how many units your transaction uses, and you get your total fee.

Example calculation:

You're sending ETH to a friend (21,000 gas) when the gas price is 25 Gwei:

  • 21,000 × 25 = 525,000 Gwei
  • 525,000 Gwei = 0.000525 ETH
  • At $2,500/ETH: roughly $1.31

Same transaction at 100 Gwei (during high demand):

  • 21,000 × 100 = 2,100,000 Gwei = 0.0021 ETH
  • At $2,500/ETH: roughly $5.25

The transaction itself doesn't change. The network congestion does.

How EIP-1559 Changed Everything

Before August 2021, Ethereum used a simple auction: you bid a gas price, and validators included the highest bidders. This created chaos during busy periods. Nobody knew the right price to bid. People massively overpaid to guarantee inclusion, and wallet estimates were often wrong by a factor of 2-3x.

EIP-1559 replaced this with a smarter system built around three components: base fee, priority fee (tip), and max fee.

Base Fee: Algorithmic Pricing

The base fee is the minimum cost per gas unit, set automatically by the protocol based on how full the previous block was:

  • Previous block more than 50% full → base fee rises up to 12.5%
  • Previous block less than 50% full → base fee drops up to 12.5%

This creates a predictable price that adjusts smoothly with demand instead of spiking chaotically. When activity drops at 3 AM, base fees naturally decrease. When a major NFT collection launches, they rise steadily as blocks fill up.

Here's the clever part: base fees get burned. The ETH disappears from circulation entirely. This makes ETH slightly deflationary during high-activity periods. Since EIP-1559 launched, over 4 million ETH has been burned through fees—worth billions of dollars that no longer exists.

Priority Fee: Your Tip to Validators

The priority fee (or "tip") goes directly to validators for including your transaction. During quiet periods, 1-2 Gwei is enough. During congestion, you might tip 10-20 Gwei or more to jump the queue.

Unlike base fee (which burns), tips create real competition for block space. When blocks are full, validators pick transactions with higher tips. Your tip determines how fast you get included, not whether you overpay for the privilege.

Max Fee: Your Safety Cap

When you submit a transaction, you set a maximum total price per gas unit (base fee + tip combined). If the actual cost comes in lower, you pay the lower amount and get the difference back automatically.

This protects you from sudden spikes. Say you set max fee at 50 Gwei when base fee is 20 Gwei. If base fee jumps to 35 Gwei before your transaction confirms, you still only pay 35 Gwei plus your tip—not 50. If base fee stays at 20, you pay 20 plus tip and the rest refunds.

The practical improvement is huge: wallet estimates are now accurate within 10-20% instead of wildly wrong. You can trust "medium speed" suggestions most of the time.

Why Some Transactions Cost More Gas

Gas usage depends on what your transaction actually does on the blockchain. More computation, more storage writes, more gas.

Storage is expensive. Writing new data to Ethereum's state—like minting an NFT, creating a new token balance entry, or deploying a contract—costs significantly more than reading existing data. This is intentional: permanent storage space is a scarce resource that every node must maintain forever.

Contract complexity matters. A simple ETH transfer updates two balances (sender and receiver). A Uniswap swap involves multiple contract interactions: checking balances, calculating new pool reserves, transferring tokens in both directions, updating liquidity ratios, and emitting events for indexers. More steps = more gas.

Token approvals add overhead. Before you can swap most tokens, you need to approve the spending—a separate transaction that costs ~45,000-50,000 gas. If you're interacting with a new DEX for the first time, you'll pay approval gas plus swap gas. After that, subsequent swaps skip the approval step.

Calldata size affects Layer 2 costs. The input data you send with a transaction—function parameters, token IDs, etc.—has a gas cost. On Ethereum mainnet this is minor, but on rollups like Base, calldata compression directly affects how much you pay since rollups post data to L1.

Here's roughly what different actions cost:

Action Typical Gas Why
ETH transfer 21,000 Minimal computation, no storage
Token transfer 50,000-65,000 Contract call + event emission
Token approval 45,000-50,000 Storage write for allowance
DEX swap 100,000-250,000 Multiple contracts, reserve updates
NFT mint 150,000-500,000 Storage for new token + metadata
Contract deployment 1,000,000+ Massive storage for code

Gas Limit: Your Transaction's Budget

Gas limit is the maximum amount of gas you authorize your transaction to consume. It's a safety cap, not a spending commitment.

If your transaction completes using less gas than your limit, you only pay for what you used—the rest refunds automatically. Set a limit of 100,000 for a transfer that uses 65,000? You pay for 65,000.

But if your transaction runs out of gas mid-execution, it fails completely. You've already paid for the computation that happened before it stopped, and you get nothing for it—no token swap, no mint, no state changes. The gas is gone.

Out-of-gas failures are expensive lessons. I once tried to mint from a complex contract with a 150,000 limit when it actually needed 200,000. The transaction burned 150,000 gas worth of ETH trying to execute, hit the limit, and reverted. No NFT, no refund. Just a failed transaction and a fee I couldn't recover.

This is different from a revert, where contract logic rejects your transaction (like slippage too high on a swap). Reverts also consume gas, but usually less than your full limit since they stop earlier.

Modern wallets add a 10-20% buffer to gas limit estimates for safety. Trust these estimates for standard operations. For experimental contracts or edge cases, tools like Tenderly let you simulate transactions before sending to see exact gas usage.

How Wallets Estimate Fees

When you open MetaMask or Coinbase Wallet and initiate a transaction, it doesn't guess randomly. The wallet:

  1. Checks current base fee from the network
  2. Scans the mempool (pending transactions) to see what tips others are offering
  3. Suggests gas limit based on similar recent transactions
  4. Offers slow/medium/fast options with different priority fees

"Slow" means a lower tip—might take several blocks to confirm but costs 20-40% less. "Fast" means a higher tip for priority inclusion in the next block.

During normal activity, wallet estimates are reliable. The problem comes during rapid demand spikes—like when 50,000 people suddenly try to mint the same NFT. Your wallet's estimate, calculated seconds ago, becomes outdated immediately. What was a reasonable 5 Gwei tip is now below hundreds of pending transactions bidding 50 Gwei.

If your transaction gets stuck because your tip is too low, you can:

  • Wait it out: fees eventually drop, your transaction confirms
  • Speed up: submit a replacement with the same nonce but higher tip
  • Cancel: submit a 0 ETH self-transfer with the same nonce

The nonce is your transaction's sequence number. Validators process nonces in order—if transaction #5 is stuck, #6 and #7 wait behind it. Replacing #5 with a higher-fee version unclogs the queue.

Layer 2: Where Fees Actually Make Sense

Everything above describes Ethereum mainnet, where median transaction costs typically range from $1-20 depending on congestion and complexity. For everyday usage—swapping tokens, minting NFTs, sending payments—these fees often exceed the transaction value itself.

Layer 2 networks solve this by processing transactions off mainnet while inheriting Ethereum's security. Base, Arbitrum, and Optimism are the major options, all reducing costs by 90-99%.

How it works: L2s batch thousands of transactions together, execute them on their own chain, then post compressed proof data back to Ethereum. The mainnet gas cost of that proof gets split across all the transactions in the batch.

The math that changes everything:

On Ethereum mainnet, a Uniswap swap at 25 Gwei:

  • ~150,000 gas × 25 Gwei = 3,750,000 Gwei = 0.00375 ETH ≈ $9.38

Same swap on Base:

  • Execution: ~150,000 gas × 0.005 Gwei = negligible
  • L1 data posting: your share of the batch ≈ $0.01-0.05
  • Total: roughly $0.02-0.10

That's 100x cheaper for the identical operation. Your wallet uses the same keys on both networks—you're just switching which chain processes your transaction.

The March 2024 Dencun upgrade (EIP-4844) made L2s even cheaper by introducing "blobs"—temporary data storage optimized for rollups. Before blobs, L2s paid full calldata prices to post proofs. Blobs cut these costs by another 90%+. NFT mints that cost $145 on mainnet now run under $1 on L2s.

For anything you do regularly—swapping, minting, moving tokens—bridging assets to an L2 pays for itself within a few transactions.

Practical Ways to Pay Less

Knowing how gas works lets you make smarter decisions about when and how you transact.

Time your transactions. Network demand follows predictable patterns. US/Europe evenings are busy; late nights and weekends are quieter. Etherscan's gas tracker shows current prices and 24-hour trends. A 30 Gwei afternoon can become 15 Gwei at 2 AM—half the cost for the same transaction.

Use "slow" speed when it doesn't matter. If you're not racing for a limited mint or arbitraging a time-sensitive opportunity, let your transaction take a few extra blocks. The 20-40% savings add up.

Batch when possible. Need three token approvals? Some protocols and wallets (like Gnosis Safe) let you bundle multiple operations into one transaction, paying base overhead once instead of three times.

Operate on L2 for regular activity. If you're swapping tokens weekly or interacting with DeFi frequently, the one-time bridge cost pays back quickly. Daily transactions that cost $10 on mainnet cost pennies on Base.

Simulate before committing. Wallet extensions with Tenderly integration show whether your transaction will succeed and exactly how much gas it'll use. Catches reverts before you waste money on them.

What to avoid:

  • Setting max fee astronomically high "just in case"—you risk overpaying if demand spikes between signing and inclusion
  • Spamming replacement transactions with small fee increases—either wait it out or bump significantly
  • Ignoring gas limit warnings—if your wallet suggests raising it for a complex contract, that's usually based on historical data from similar transactions

Reading Block Explorer Fee Breakdowns

After any transaction, you can examine exactly what you paid on Etherscan (mainnet) or Basescan (Base). Look for:

  • Gas Used: Actual units consumed (vs. your limit)
  • Base Fee: Per-unit base fee when your transaction was included
  • Max Priority Fee: Your maximum tip offer
  • Effective Price: What you actually paid per unit (base + actual tip)
  • Transaction Fee: Total cost in ETH

If your transaction failed, the status shows "Reverted" or "Failed." Check if gas used equals your limit—that's an out-of-gas error, and you need a higher limit next time. If gas used is less than limit but it still failed, the contract rejected your transaction for a logical reason (slippage, insufficient balance, etc.).

On Basescan, fees split into L2 execution gas and L1 data fee. This transparency shows exactly how the cost breaks down and confirms the massive savings versus mainnet.

Ethereum's roadmap prioritizes making fees irrelevant for everyday users. The Dencun upgrade already slashed L2 costs. Future upgrades will increase blob capacity, potentially 10x again, making L2 transactions essentially free.

The long-term vision: Ethereum mainnet becomes the security and settlement layer, while L2s handle all regular activity at negligible cost. Mainnet gas fees will still exist—they'll just become something only large-value operations and institutional users worry about.

For now, understanding gas mechanics gives you an edge. You'll time transactions better, avoid overpaying, and stop losing money to preventable failures. Combined with L2s, onchain activity becomes affordable enough that fees stop being a barrier to what you want to do.


Gas fees are the cost of using decentralized infrastructure without intermediaries. They compensate the people running the network, prevent spam, and manage limited capacity. The EIP-1559 upgrade made pricing predictable. Layer 2s made it affordable.

The knowledge in this guide—how gas units, Gwei, and tips combine into your fee, why some actions cost more, how to read fee breakdowns—turns opaque charges into predictable math you control. Whether you're sending your first ETH transfer or optimizing DeFi operations, these fundamentals apply universally. Master them once, and gas fees become a manageable part of onchain life rather than an expensive mystery.