start learning →
intermediate11 min read

Crypto gas fees explained: gwei, base fees, spikes and layer 2s

Gas fees are what you pay a blockchain to process your transaction. Here is how Ethereum fees are built from gas used, base fee and tip, why they can jump tenfold in minutes, how Bitcoin and Solana fees differ, and how layer 2s cut costs.

key takeaways
  1. On Ethereum, the fee is gas used multiplied by the price per unit of gas, which is the base fee plus an optional tip; prices are quoted in gwei, a billionth of an ether.
  2. The base fee can rise by up to 12.5% per block when blocks are full, so a burst of demand can multiply fees several times within a few minutes.
  3. A failed transaction still pays for the gas it used, and complex smart-contract actions use far more gas than a simple transfer.
  4. Bitcoin fees are priced per unit of transaction size (satoshis per virtual byte), not per unit of computation.
  5. Crypto CFD traders do not pay gas at all; it matters only when you move coins on a blockchain yourself or withdraw from an exchange.

A gas fee is the payment you make to a blockchain's validators or miners to process your transaction. On Ethereum, every action uses a measured amount of computation called gas, and you pay for each unit of gas at a price that rises and falls with demand for space in the next block. Fees are quoted in gwei, one billionth of an ether, and they can jump many times over in minutes when lots of people try to transact at once.

The Ethereum and altcoins guide introduces gas with a simple transfer example. This guide goes further: how the base fee is set block by block, what the gas limit and max fee settings in your wallet actually do, why failed transactions still cost money, how Bitcoin and Solana price their fees differently, and what layer 2 networks change.

Risk warning: crypto assets are highly volatile, and blockchain transactions usually cannot be reversed. Mistakes with fees, addresses or networks can lose funds permanently.

Why blockchains charge fees at all

A blockchain can only fit a limited amount of activity into each block. Fees do two jobs:

  • Rationing space. When more people want to transact than the block can hold, those willing to pay more go first.
  • Preventing spam. If transactions were costless, anyone could flood the network with junk.

Part of the fee also pays the people who secure the network: validators on proof-of-stake chains such as Ethereum, miners on proof-of-work chains such as Bitcoin.

The units: gas, gwei and ether

Three units are easy to confuse.

  • Gas measures work. A plain ether transfer uses 21,000 gas. Swapping tokens on a decentralised exchange might use 100,000 to 200,000 or more, depending on the contract.
  • Gwei measures price per unit of gas. One gwei is 0.000000001 ETH.
  • Ether (ETH) is what you actually pay with.

So the formula is: fee in ETH = gas used x price per gas in gwei / 1,000,000,000. To get a figure in euros or dollars, multiply by the ether price.

How the Ethereum fee is built

Since the London upgrade in August 2021 (EIP-1559), the price per gas has two parts.

  • Base fee. Set by the protocol for each block, the same for everyone in that block. It is burned, meaning destroyed, not paid to anyone.
  • Priority fee (tip). Set by you, paid to the validator who includes your transaction. A bigger tip can get you included sooner when blocks are busy.

Your wallet also lets you set two caps:

  • Gas limit: the maximum gas the transaction may use. Wallets estimate it for you.
  • Max fee per gas: the most you are willing to pay per unit, base fee plus tip combined.

You pay the base fee plus your tip, as long as that total is below your max fee. If the base fee rises above your max fee, your transaction waits until it falls again.

Worked example: what you actually pay

Illustrative numbers only. You swap tokens on a DEX. Your wallet sets a gas limit of 180,000, a max fee of 40 gwei and a tip of 1.5 gwei. When your transaction is included, the base fee is 22 gwei, and the swap uses 142,000 gas.

  • Price per gas: 22 + 1.5 = 23.5 gwei, which is under your 40 gwei cap.
  • Fee: 142,000 x 23.5 = 3,337,000 gwei = 0.003337 ETH.
  • Of that, 142,000 x 22 = 3,124,000 gwei (0.003124 ETH) is burned and 142,000 x 1.5 = 213,000 gwei (0.000213 ETH) goes to the validator.
  • At an illustrative ether price of 3,000 dollars, the fee is about 10.01 dollars.

You are charged for the 142,000 gas used, not the 180,000 limit. The unused gas costs nothing.

Why gas fees spike

Ethereum targets blocks that are half full. After each block, the base fee adjusts:

  • if the block was more than half full, the base fee rises, by up to 12.5% for a completely full block;
  • if it was less than half full, the base fee falls, by up to 12.5% for an empty block.

Blocks arrive roughly every 12 seconds. A run of full blocks therefore compounds quickly.

Worked example: twenty full blocks

Illustrative numbers only. The base fee is 20 gwei and demand suddenly surges, so every block is full.

  • After 1 block: 20 x 1.125 = 22.5 gwei.
  • After 10 blocks (about two minutes): 20 x 1.125 to the power of 10, about 64.9 gwei.
  • After 20 blocks (about four minutes): about 211 gwei.

A simple transfer of 21,000 gas would have cost 0.00042 ETH at 20 gwei and about 0.0044 ETH at 211 gwei, more than ten times as much, in four minutes. The same mechanism brings fees back down once demand fades.

What causes the surges

  • Sharp market moves. In a sell-off, people rush to move coins to exchanges, repay loans or add collateral, and automated liquidations on lending platforms fire all at once. See crypto volatility and risk.
  • Popular launches. Token sales, NFT mints and airdrop claims bring thousands of users at the same moment.
  • Bots competing. Arbitrage and liquidation bots bid up tips to get ahead of each other.
  • Fewer people using layer 2s for a given activity, so it lands on the main chain.

Failed transactions still cost gas

If a transaction fails, for example because a DEX price moved beyond your slippage tolerance or a contract rejected it, the work done up to the failure has already been performed. You pay for the gas consumed, and nothing else happens. In some failures, such as running out of gas, the whole gas limit is consumed.

Worked example: a failed swap

Illustrative numbers only. You submit a swap during a busy period with a base fee of 80 gwei and a tip of 2 gwei. The price moves and the swap reverts after using 45,000 gas.

  • Fee: 45,000 x 82 = 3,690,000 gwei = 0.00369 ETH, about 11.07 dollars at 3,000 dollars per ETH.
  • Tokens received: none.

This is why setting an unrealistically tight slippage tolerance at a hectic moment can cost you fees for nothing, and why setting a very loose one exposes you to a poor fill. The how crypto exchanges work guide explains price impact on DEX pools.

Common gas-hungry actions

Fees scale with gas used, so the type of action matters as much as the gas price.

  • Simple ETH transfer: 21,000 gas.
  • Token transfer (for example a stablecoin): more than a plain ETH transfer, because it calls the token's contract.
  • Token approval: a separate transaction that lets a contract spend your tokens; you pay for it once per token and contract.
  • DEX swap: typically well above a token transfer, more if it routes through several pools.
  • Lending, staking or bridging: often among the most expensive, because several contracts interact.

Exact gas use depends on the contract. Your wallet shows an estimate before you confirm.

Bitcoin fees: paying for size, not computation

Bitcoin has no gas. Its fees are set by the size of the transaction in virtual bytes (vB), and you bid a rate in satoshis per virtual byte (sat/vB). One satoshi is 0.00000001 BTC. Miners pick transactions that pay the highest rate per byte, and unconfirmed transactions wait in a queue called the mempool.

Size depends on how many inputs (coins you are spending) and outputs (recipients and change) the transaction has, not on how much bitcoin is sent. Sending 0.01 BTC can cost the same as sending 100 BTC.

Worked example: a bitcoin transfer

Illustrative numbers only. A transaction with one input and two outputs is about 141 vB. At a fee rate of 20 sat/vB:

  • Fee: 141 x 20 = 2,820 satoshis = 0.0000282 BTC.
  • At an illustrative bitcoin price of 60,000 dollars: about 1.69 dollars.

If the mempool is crowded and you bid 150 sat/vB to confirm in the next block, the same transaction costs 21,150 satoshis, about 12.69 dollars. A wallet holding many small deposits may need dozens of inputs to send one payment, which makes the transaction, and the fee, much larger. Combining small coins when fees are low is a common habit for that reason.

Bitcoin's Lightning Network moves many payments off the main chain and settles them later, so individual payments cost very little. The layer 2 scaling guide covers it.

Solana and other chains

Different blockchains price fees in different ways.

  • Solana charges a small base fee per signature, 5,000 lamports (a lamport is a billionth of a SOL), plus an optional priority fee that rises when particular programs or accounts are in heavy demand. Ordinary fees are usually a tiny fraction of a cent, but priority fees can climb during busy token launches. See Solana explained.
  • Other smart-contract chains often copy Ethereum's gas model with their own native token.

Cheaper fees usually come from design choices, such as higher throughput or more demanding hardware for validators, which carry their own trade-offs on decentralisation and reliability.

Layer 2 networks and why their fees are lower

Layer 2 networks, often called rollups, execute transactions off the Ethereum main chain and post compressed batches of data back to it. Thousands of transactions share the cost of one posting, so each user pays a fraction.

The Dencun upgrade in March 2024 added a cheaper type of data space for rollups, known as blobs (EIP-4844), and layer 2 fees fell sharply after it. A layer 2 fee is roughly:

  • the cost of running your transaction on the rollup, plus
  • your share of the cost of posting data to Ethereum.

Layer 2s bring their own risks: the software of the rollup itself, the operator that orders transactions, and bridges used to move funds in and out. Moving funds back to Ethereum from some rollups can take days unless you pay a third-party bridge. Our layer 2 scaling guide compares the main designs.

Exchange withdrawal fees are not the same as gas

When you withdraw from a centralised exchange, it sends the coins on-chain and pays the network fee. Most charge you a flat withdrawal fee per asset and network, which may be set above or below the live network fee and may not change as quickly. Trades inside an exchange have no gas at all, because they are entries on the exchange's internal ledger.

Choose the network carefully when withdrawing. The same stablecoin may be offered on Ethereum, a layer 2 and other chains at very different fees, but the receiving wallet or platform must support the network you pick.

Do CFD traders pay gas fees?

No. A crypto CFD is a contract with your broker that tracks a price. No coins move on a blockchain, so there is no gas, no wallet and no network to choose. Your costs are the spread and overnight financing, explained in crypto CFD overnight fees. The trade-off is that you never own the coins; the crypto CFDs vs buying crypto guide compares the routes.

Gas still matters indirectly. Fee spikes often coincide with sharp moves and liquidations, which is also when CFD spreads tend to widen. See why spreads widen.

How to keep fees down

  • Check the fee before confirming. Wallets show an estimate in gwei and in currency.
  • Avoid busy moments when you can. Fees are usually lower when activity is quieter. Gas trackers show the current base fee.
  • Use a layer 2 or a cheaper network for small, frequent transactions, if your platform supports it.
  • Batch actions. One larger transfer costs the same gas as one small one.
  • Do not overpay the tip. In calm periods a small tip is enough; your wallet's suggestion is usually sensible.
  • Set a sensible max fee. Too low and your transaction may sit unconfirmed; too high only matters as a cap, since you pay the actual base fee plus tip.
  • Watch for fake gas refund offers. Messages promising to refund your fees are a common phishing lure.

Common mistakes

  • Confusing gas limit with gas price. The limit caps units of work; the price is what each unit costs.
  • Holding no ether for gas. You cannot send a token on Ethereum without ETH to pay the fee, even if the token is worth thousands.
  • Retrying a failing transaction repeatedly, paying gas each time, instead of finding out why it fails.
  • Withdrawing on the wrong network to save fees, when the receiving platform does not support it.
  • Ignoring approval transactions when estimating the cost of a DeFi action.
  • Assuming a cheap chain is always cheap. Priority fees and congestion can change that quickly.
  • Treating fees as small for small amounts. A 10 dollar fee on a 50 dollar transfer is a 20% cost.

Frequently asked questions

What is gwei?

Gwei is a unit of ether used to quote gas prices. One gwei is one billionth of an ether (0.000000001 ETH). A gas price of 20 gwei means each unit of gas costs 0.00000002 ETH.

Why are Ethereum gas fees so high sometimes?

Because the base fee rises automatically when blocks are full, by up to 12.5% per block. During sudden demand, such as a market sell-off or a popular launch, a run of full blocks can multiply the base fee several times in a few minutes.

Do I get my gas back if a transaction fails?

No. You pay for the gas used up to the point of failure. Unused gas below your gas limit is not charged, but the gas consumed is gone.

Who receives the gas fee?

On Ethereum, the base fee is burned and the priority fee goes to the validator who includes the transaction. On Bitcoin, the whole fee goes to the miner.

Are bitcoin fees calculated the same way as Ethereum gas?

No. Bitcoin charges by the transaction's size in virtual bytes at a rate in satoshis per virtual byte. The amount of bitcoin sent does not affect the fee; the number of inputs and outputs does.

Do I pay gas when trading crypto CFDs?

No. CFDs do not involve moving coins on a blockchain. You pay the broker's spread and overnight financing instead. Use the crypto position size calculator to size CFD trades.

Not investment advice. This is general information and education, written without knowledge of your circumstances. It is not a recommendation to buy or sell any instrument. Past performance is not a reliable indicator of future results. Trading leveraged products carries a high risk of losing money. Risk warning