Gas Fees Explained: Why Transactions Cost Money

Gas Fees Explained: EIP-1559, EIP-4844 Blobs, L2 Fee Anatomy (Complete guide)

Gas fees explained means you can answer three practical questions without guessing: (1) what you are paying for, (2) why fees spike, and (3) how to reliably pay less without getting stuck or sandwiched. This TokenToolHub guide breaks gas down from first principles, then builds back up through EIP-1559, blob data after EIP-4844, rollup fee math, and step-by-step playbooks you can use in a wallet today.

Prerequisite reading: If you want a clean foundation first, start with Blockchain Technology Guides. If you are already exploring rollups and advanced transaction flows, continue in Blockchain Advance Guides.

TL;DR

  • Gas is a meter. It measures how much compute, storage, and data your transaction consumes. Fees price scarce block space and keep networks spam-resistant.
  • Post EIP-1559 on Ethereum: you pay gasUsed × (baseFee + tip). Base fee is algorithmic and burned. Tip is an incentive for inclusion.
  • Max fee is a ceiling. If you set a high maxFee, you are not automatically overcharged. Unused headroom is refunded by protocol rules.
  • Most fee pain is congestion + wasted attempts. Spikes happen when demand outpaces block capacity, and when users retry failing swaps or mints.
  • L2 fees are two fees in a trench coat. You pay for execution on the rollup plus data availability to Ethereum. Blobs after EIP-4844 aim to make the data part cheaper.
  • Pay less by changing behavior, not by hoping. Use L2 for routine activity, transact off-peak, batch actions, avoid unnecessary approvals, simulate before signing, and use MEV-aware routing for sensitive swaps.
  • Best habit: treat every transaction as a decision with three levers: urgency, failure risk, and venue (L1 vs L2).
Core framing Gas is not a tax, it is a pricing system for shared compute

When you use a blockchain, you are requesting work from thousands of nodes and validators. That work is not free, and it cannot be unlimited. Gas is the network’s way to (a) measure the work, and (b) allocate limited capacity to the requests that value it most right now.

If you understand gas, you stop losing money in two common ways: you stop overpaying during hype, and you stop burning fees on failed transactions.

What gas is, and why it exists

Start with the simplest mental model: a blockchain is a shared computer that everyone is allowed to use. If usage was free and unlimited, spammers could send endless transactions and make the system unusable. So blockchains impose a cost on usage, and a limit on capacity per block. Gas is the accounting unit used to measure how expensive your transaction is for the network to run.

A transaction can cost gas for multiple reasons: verifying signatures, executing smart contract code, reading from state, writing to state, and publishing input data. Some operations are cheap, others are expensive, and the schedule is designed so expensive operations reflect real resource burden.

Problem
Unlimited demand
Many users want inclusion at once, especially during mints, launches, and volatility.
Constraint
Limited block space
Blocks can only include so much compute and data per unit time.
Solution
Fee market
Users pay to compete for inclusion. Higher-value txs outbid lower-value txs.
Why gas exists Demand competes for limited capacity, fees allocate inclusion. Users Swaps, mints, transfers Each has gas cost Each has urgency Fee market Price per unit gas Base fee (protocol) Tip (priority) Transactions sorted Block Limited Capacity Inclusion If demand rises, price rises. If demand falls, price falls. Your job is to choose the cheapest safe moment and venue.
ELI5 Gas is the meter on a taxi, not the taxi itself

The blockchain is the taxi. Your transaction is the ride. Gas measures how long and complicated the ride is, and the fee market determines the price per unit right now.

Gas units vs gas price vs total fee

People often say gas when they mean fee. Separate the concepts: gas units measure work, gas price is what you pay per unit, and fee is units times price.

  • Gas units: how much your transaction uses. A simple ETH transfer is famously around 21,000 gas units.
  • Base fee: a protocol-driven price per gas unit on Ethereum after EIP-1559.
  • Priority fee (tip): a user-specified incentive to get included sooner.
  • Total fee: gasUsed × (baseFee + effectiveTip), denominated in ETH on Ethereum.
// Ethereum post EIP-1559 (conceptual)
effectiveTip = min(maxPriorityFeePerGas, maxFeePerGas - baseFeePerGas)
totalFeeETH  = gasUsed * (baseFeePerGas + effectiveTip) / 1e9  // gwei to ETH
          
Important A higher max fee does not mean you pay that max

Wallet UIs can make this confusing. On EIP-1559, maxFee is a ceiling that protects you from sudden base fee jumps while your transaction is pending. If the base fee at inclusion is lower, the protocol refunds the unused headroom. The only amount you truly pay is what the network needed at inclusion time.

EIP-1559: the modern Ethereum fee market

Before EIP-1559, Ethereum used a first-price auction where users guessed a single gas price and hoped it was enough. That produced ugly fee volatility and poor user experience. EIP-1559 changed the game by splitting the fee into two parts: an algorithmic base fee and a user-controlled tip.

Base fee: algorithmic and burned

The base fee adjusts from block to block depending on demand relative to a target block size. If recent blocks are fuller than target, the base fee rises. If blocks are emptier than target, the base fee falls. On Ethereum, the base fee is burned, which means it is removed from circulation rather than paid to validators. This aligns incentives: congestion costs users, but it does not create a direct bribe to overfill blocks with spam.

Priority tip: inclusion incentive

The tip is the part that directly incentivizes block proposers to prioritize your transaction. In practice, the tip you need depends on how competitive the mempool is and how quickly you want to be included. In calm conditions, a modest tip can be enough. In a hot mint or market panic, you may need more to compete.

EIP-1559 wallet settings you should recognize

  • Max priority fee: your tip ceiling.
  • Max fee: your all-in ceiling (base + tip).
  • Estimated base fee: what the network currently requires.
  • Gas limit: max units your transaction can consume before it stops.

Fee math with real examples you can sanity-check

When you learn gas, you want examples that feel like a receipt. The goal is not perfect accuracy to the last digit, the goal is confidence that you can spot nonsense.

Example 1: simple ETH transfer

A basic ETH transfer commonly uses about 21,000 gas units. Assume the base fee is 20 gwei and you set a 2 gwei tip.

gasUsed = 21000
baseFee = 20 gwei
tip     = 2 gwei

total = 21000 * (20 + 2) = 462000 gwei
totalETH = 462000 / 1e9 = 0.000462 ETH
          

Example 2: swap and why it costs more

A swap is not one operation, it is a series of contract calls: token transfer logic, pool math, storage reads and writes, and sometimes routing through multiple pools. That is why a swap can be 100,000 to 250,000 gas units or more depending on route and token behavior. If gasUsed is 180,000 and your all-in price is 22 gwei, the fee is 3,960,000 gwei, which is 0.00396 ETH.

Common pitfall The expensive part is often failing and retrying

A swap that fails due to slippage or insufficient allowance still burns gas up to the revert point. If you retry three times during a spike, the fee can exceed what you were swapping. Simulation and realistic slippage settings save money faster than tip tweaking.

Refund intuition: why high maxFee does not overcharge you

Many users avoid raising maxFee because they think they will pay it. The protocol does not do that. The inclusion price is determined by the base fee at inclusion time plus the effective tip. If you set maxFee far above that, the difference is not spent. It is refunded as unused headroom.

gasUsed = 100000
baseFeeAtInclusion = 15 gwei
maxPriorityFee = 1.5 gwei
maxFee = 60 gwei

effectiveTip = min(1.5, 60 - 15) = 1.5 gwei
paid = 100000 * (15 + 1.5) = 1,650,000 gwei = 0.00165 ETH

Unused headroom exists (maxFee - baseFee - tip), and is not paid.
          

Gas limit vs gas used, and why failures hurt

Gas limit is the cap you are willing to spend in gas units. Gas used is what actually gets consumed. In successful transactions, you typically pay for gas used. In failed transactions, the story is harsher: you pay for the work performed until the failure, and in an out-of-gas failure you may burn the entire limit.

Outcome What it means Do you pay? Common causes Best prevention
Success State change is applied Yes, gas used Normal execution Reasonable settings
Revert Execution intentionally stops and rolls back state changes Yes, gas burned until revert Slippage, permission checks, deadline expired Simulate, adjust params
Out-of-gas Execution runs out of allowed gas Usually yes, up to the limit Too low gas limit, complex call path Use wallet estimates, avoid manual low limits
Stuck pending Not included yet Not until included Fee too low for current market Speed up, replace, cancel

Stuck transaction playbook

  • Speed up: resend a replacement transaction with the same nonce and a higher effective fee.
  • Cancel: send a 0 value transaction to yourself with the same nonce and higher fee (if your wallet supports it).
  • Do not spam resend: repeated failures burn fees and can create messy nonce gaps.
  • Check the mempool reality: if base fee has risen above your max fee, the tx cannot be included until base fee drops or you replace it.

What actually costs gas inside the EVM

You do not need to memorize opcode prices, but you should understand the shape: storage writes cost a lot, data costs something, and repeated work costs more. This matters because many high fees are self-inflicted by contract design, token design, or dApp behavior.

Storage reads and writes: the expensive stuff

Storage is durable state that all nodes must replicate. Writing to storage is expensive because it increases or modifies global shared state. Reading storage is cheaper than writing but not free, and the first access to a slot in a transaction can be more expensive than subsequent accesses.

For users, the takeaway is practical: interactions that modify lots of state (complex DeFi, multi-hop swaps, heavy NFT mints) cost more gas units. For builders, the takeaway is to avoid unnecessary storage writes and avoid unbounded loops.

Calldata: paying to publish inputs

When you call a contract, your input data is included in the transaction. That data is stored as calldata and becomes part of the permanent chain record. Posting data consumes block space even if compute is small. This is why some transactions can be data-heavy rather than compute-heavy.

Key shift Rollups paid heavily for calldata, blobs aim to make data cheaper

Before blobs, rollups often posted compressed transaction data to Ethereum as calldata. During congestion, that data became expensive. With blob-carrying transactions, the network introduces a separate pricing lane for rollup data, designed to scale without permanently bloating Ethereum execution state.

Gas refunds: why old tricks do not matter in 2025

Older eras of Ethereum saw strategies like gas tokens, where users stored data when gas was cheap and cleared it when gas was expensive to receive refunds. Refund rules were changed to reduce abuse and to keep block space allocation honest. For normal users, the practical message is simple: do not expect clever refund schemes to beat the fee market. Your best savings come from timing, venue, batching, and reducing failures.

EIP-4844 and blobs: what changed for L2 fees

Layer 2 rollups execute transactions off-chain and rely on Ethereum for security by publishing enough data to reconstruct the rollup state. That data publication is called data availability. Historically, a big part of your L2 fee was the cost to post data to Ethereum, often as calldata.

EIP-4844 introduces blob-carrying transactions, commonly called blobs. Blobs are designed for rollup data: large chunks of data that are available for a time window and priced by a separate fee mechanism. The key point is not the implementation detail, the key point is the economics: rollup data gets its own market so it can be cheaper and scale independently from the normal EVM execution gas market.

L2 fee anatomy User pays for execution on the rollup plus publishing data to Ethereum. Your L2 transaction Swap, mint, transfer Signed in your wallet Sent to sequencer Execution fee L2 compute and state Sequencer pricing Data availability fee Publishing to Ethereum Often via blobs Ethereum Security DA layer Settlement L2 savings come from cheaper execution and more efficient data posting. When L1 data pricing changes, L2 fee dynamics can change too.

Reality check: blobs help, but do not delete fee markets

Blobs are not magic free transactions. They change which resource is scarce and how it is priced. If blob demand grows, blob pricing can rise. If Ethereum mainnet is extremely congested, some fee pressure can still be transmitted to rollups through settlement and data posting. The reason users still win is that rollups batch many user transactions into fewer L1 publications, so each user pays a fraction of L1 cost.

Ethereum L1 vs L2: when to use which in 2025

In 2025, most everyday activity should happen on L2 unless you have a specific reason to be on L1. L1 is the premium venue: highest security, highest composability baseline, and highest cost at peak demand. L2 is the practical venue: lower fees for routine actions, often faster confirmations, and a smoother experience for small transactions.

Use case Prefer L2 Prefer L1 Why
Small swaps and routine DeFi Yes Sometimes Fees on L2 are typically far lower, so you waste less on retries.
Minting with low expected value Yes No If it fails, you lose less. Hype mints on L1 are where fee burn is most brutal.
High-value settlement Depends Often L1 can be preferred for final settlement of very large value, depending on your risk model.
Bridging and on-ramps Often Sometimes Direct to L2 on-ramps can avoid a costly L1 deposit during congestion.
Protocol governance operations Maybe Maybe Depends where the governance lives. Follow the protocol’s canonical venue.
Principle Venue choice is a fee decision

You save the most money by avoiding expensive venues for actions that do not justify them. If the action is experimental, low value, or likely to fail, put it on the cheapest safe venue available. Reserve L1 for when you explicitly need L1.

How to pay less: a step-by-step gas saving system

Paying less is not one trick. It is a system that reduces your expected fee burn over time. Think like a professional: you are managing a cost function under uncertainty. Here is a system that works.

Step 1: Time non-urgent transactions

Base fee is demand-driven. That means the network has cheaper and more expensive windows. Your first lever is time. If a transaction is not urgent, you should not execute it at the same moment everyone else is rushing.

Timing checklist

  • Use a gas tracker to see current base fee and recent history.
  • If the action can wait, wait for a calmer window and re-check.
  • Avoid major news spikes and popular mint windows if your transaction is not related.
  • If you are on L1, treat peak hours as premium pricing.

Step 2: Move routine activity to L2

Routine activity is the perfect candidate for rollups: swaps, approvals, farming actions, smaller mints, games, and experiments. On L1, these actions can be expensive and psychologically costly. On L2, they are often cheap enough that you can behave more safely, meaning you can pause, simulate, and re-try without burning a week’s worth of small fees.

Note Bridging can be the expensive part

If you must bridge from L1 to L2 during congestion, the deposit transaction can be expensive. When possible, consider direct on-ramps to the destination L2 so you avoid paying L1 fees just to get started.

Step 3: Batch actions and reduce extra approvals

Many users pay extra fees because they perform actions in separate transactions. Classic example: approve, then swap. Approvals are permissions, and many dApps require them. But there are ways to reduce how often you do them.

  • Batching: some dApps support multicall style flows so multiple actions are performed in one transaction.
  • Permit style approvals: some tokens support signature-based approvals (permit), which can remove the separate approve transaction and fold permission into the swap.
  • Reuse allowances carefully: if you trust the spender, you can avoid repeated approvals, but do not turn convenience into unlimited risk.
Safety meets fees Unlimited approvals can be cheaper, and also dangerous

Many drain events happen through approvals. When you choose convenience, you expand blast radius. A more professional approach is: keep approvals minimal for valuable tokens, and use an activity wallet for experiments.

Step 4: Simulate before sending to avoid fee burn

The fastest way to reduce gas spend is to reduce failed transactions. Failed swaps, failed mints, failed bridges, and failed contract calls burn gas with nothing to show. Simulation is your best friend.

Simulation checklist

  • Check whether your wallet offers transaction simulation or warnings.
  • Use realistic slippage and deadlines for swaps, especially during volatility.
  • Ensure you have enough token balance and enough native token for fees.
  • Verify allowance and spender address before approving or swapping.
  • If you see repeated failures, stop and diagnose. Do not brute force the chain with retries.

Step 5: Use MEV-aware routing for sensitive swaps

MEV is a separate dimension of cost. It can turn a cheap swap into an expensive outcome through worse execution price. In public mempools, attackers can observe your swap and attempt sandwich strategies. MEV-protected routing aims to reduce this by sending transactions through private paths to block builders or validators.

The result is not always perfect, but it is a strong default for sensitive swaps. It also reduces wasted attempts caused by aggressive mempool competition.

MEV and routing Public mempool exposes intent. Private routing reduces exposure for sensitive actions. Path A: public mempool Wallet broadcasts to public mempool Searchers can see swap and compete Potential sandwich and worse execution Higher hidden cost than gas Path B: protected routing Wallet sends to MEV-aware endpoint Transaction delivered privately to builders Reduced mempool exposure More predictable execution Decision rule If you are swapping a meaningful amount, or price impact matters, prefer protected routing. If the transaction is trivial, normal routing can be fine. Gas fee is visible cost. MEV and failed attempts are hidden costs you should control.

Case studies: what you pay for common actions

The fastest way to internalize gas is to map it to actions you actually take. Below are the common actions that create the most confusion, plus the fee levers that matter.

Case 1: sending ETH

This is a mostly fixed gas unit action. The fee is driven mainly by the base fee and your tip. If the network is calm, it is cheap. If the network is congested, it becomes expensive even though the computation is simple, because you are competing for block space.

Case 2: approve plus swap

Approval is a separate transaction that creates a permission from your address to a spender contract. That means it costs gas and it creates risk. Many users pay twice and then pay again when swaps fail. The professional routine is: verify spender, set minimal allowance, simulate, and prefer venues where failures are cheap.

Case 3: NFT mint during a rush

Mints create the worst user behavior: people panic, raise fees, and spam retries. If the mint contract is popular, the base fee rises quickly. If the mint has a strict supply cap, many transactions fail after the cap is hit. Those failures burn gas.

Mint survival checklist

  • Decide your max loss before you mint. If the expected value is low, do not bid premium fees.
  • Prefer mints on L2 when possible.
  • If you miss, do not chase by retrying repeatedly during peak congestion.
  • Use a wallet that clearly displays the contract and function being called.

Case 4: bridging to an L2

Bridging is often a single L1 transaction (deposit) plus L2 execution on the destination. The pain comes when L1 is congested. The strategy is to plan your bridge ahead of time and avoid bridging during a spike unless you must. If you are building a recurring routine, direct to L2 on-ramps can reduce your L1 exposure.

Caution Cheap activity can be ruined by expensive entry

Many users save money on L2 but lose the savings by bridging at peak times. If you know you will use L2 often, treat bridging like a planned action, not an impulse.

MEV, the mempool, and hidden cost beyond gas

Gas is the visible fee you pay to the network. MEV is the hidden cost you can pay through worse execution. If you swap in a public mempool, your transaction can be observed before it is included. Sophisticated actors can react to your transaction by placing transactions around it to profit. The most well-known version for users is sandwiching on swaps.

This is why paying less is not just about lowering base fee. Paying less is about reducing your all-in cost, including slippage and execution quality. In practice, the best defense is to use MEV-aware routing for large swaps, and to keep slippage reasonable.

Myths that make people lose money

  • Myth: higher gas limit means higher fee. Reality: you pay for gas used, except in out-of-gas failures.
  • Myth: validators set the base fee. Reality: base fee is algorithmic under EIP-1559.
  • Myth: raise the tip and any transaction will succeed. Reality: tips buy priority, they do not fix logic errors or slippage issues.
  • Myth: L2 fees are independent from L1. Reality: rollups still pay for data availability and settlement that depends on Ethereum conditions, although blobs change the dynamics.
  • Myth: cheap fees mean safe transactions. Reality: cheap transactions can still approve drainers and malicious contracts.

Your gas-saving toolbox

Tools do not replace understanding, but they reduce mistakes. Here is a practical toolbox that matches the system above.

Trackers
Time your actions
Use gas trackers to see current base fee and choose calm windows.
Simulation
Prevent failures
Simulate swaps and mints to avoid paying for guaranteed reverts.
MEV routing
Protect execution
Use MEV-aware endpoints for sensitive swaps to reduce sandwich exposure.

A simple weekly routine that reduces gas spend

  • Use L2 for daily actions. Keep L1 for planned, high-value actions.
  • Before any swap, check allowance, slippage, and simulation if available.
  • Once a month, review and revoke old approvals, especially from experiment wallets.
  • For large swaps, use MEV-aware routing and avoid peak hype windows.
  • For bridges, plan entry and avoid peak base fee spikes when possible.

Quick check

Use this to test your understanding before you move on.

  1. What are the two main parts of an Ethereum fee after EIP-1559?
  2. Why can a transaction fail and still cost money?
  3. What are the two major components of a rollup fee?
  4. Name three reliable ways to pay less without guessing.
Show answers

1) Base fee (algorithmic, burned) and priority tip (incentive for inclusion). 2) You pay for computation performed until the failure point, and out-of-gas can burn the entire limit. 3) Execution fee on the rollup plus data availability and settlement costs to Ethereum (often via blobs for data). 4) Use L2 for routine activity, transact off-peak, batch actions or reduce extra approvals, simulate before sending, and use MEV-aware routing for sensitive swaps.

Turn fee knowledge into a cheaper, safer workflow

The goal is not to chase the lowest number on a gas tracker. The goal is to minimize total cost over time: fewer failures, fewer retries, and better venue choices. If you want to go deeper into rollups, fee dynamics, and advanced execution habits, continue with advanced guides.

Safety note: saving gas is great, but never trade safety for a cheaper fee. Verify contracts, minimize permissions, and keep a separate wallet for experiments.

FAQs

What exactly do I pay on Ethereum after EIP-1559?

You pay gasUsed × (base fee + effective priority tip). Base fee is determined by the protocol and is burned. The tip is what incentivizes inclusion. If you set a max fee above what is needed at inclusion, the unused headroom is not paid.

Why do L2 fees sometimes rise when Ethereum is busy?

Rollups still post data and settle to Ethereum. When Ethereum is congested, the cost of those operations can rise. The reason L2 is usually still cheaper is batching: many user transactions share the cost of a smaller number of L1 publications.

Does increasing gas limit increase my fee?

Not directly. In a successful transaction you pay for gas used, not the limit. The limit matters because if it is too low and the transaction runs out of gas, you can burn the limit without success.

How can I avoid burning gas on failed swaps?

Simulate when possible, set realistic slippage, ensure you have sufficient balance and allowance, and avoid retry spamming during congestion. If it keeps failing, stop and diagnose rather than brute forcing the chain.

When should I consider MEV-aware routing?

If you are swapping a meaningful amount, or price impact matters, MEV-aware routing can reduce exposure to sandwich behavior in public mempools. For small swaps, normal routing is often fine.

References

Foundational specs and reputable resources for deeper reading:


Final reminder: fees are only the visible part of cost. The invisible cost is failures, retries, and bad execution. Choose the right venue, simulate before signing, and treat urgency as a premium you pay only when it is truly necessary.

About the author: Wisdom Uche Ijika Verified icon 1
Founder @TokenToolHub | Web3 Research, Token Security & On-Chain Intelligence | Building Tools for Safer Crypto | Solidity & Smart Contract Enthusiast