Gas and Transaction Fees

Why blockchain transactions cost a fee, how gas works on Ethereum, what gwei and the burned base fee are, and how fees work on Bitcoin.

4 min · 798 wordsUpdated: #basics#fees#gas#ethereum

Almost every action on a public blockchain costs a small fee. Sending coins, swapping tokens, minting an NFT: each of these is a transaction, and someone has to pay for the network to process it. On Ethereum and similar networks this fee is described in terms of gas. On Bitcoin it is simply called a transaction fee. This article explains why fees exist and how they are calculated.

Why blockchains charge fees

Fees solve two problems at once.

  • Paying for security: miners or validators do real work to keep the network running, and fees are part of their reward.
  • Preventing spam: space in each block is limited. If transactions were free, anyone could flood the network with junk. A fee makes that expensive and lets the network decide which transactions go first when demand is high.

Because block space is limited, fees behave like a market. When many people want to transact at the same time, they compete for space and fees rise. When the network is quiet, fees fall.

Gas on Ethereum

On Ethereum, every operation a transaction performs has a fixed cost measured in units of gas. A simple ether transfer uses a small, fixed amount of gas. Interacting with a smart contract, for example a swap on a decentralized exchange, usually requires more because the network has to perform more computation and store more data.

It helps to separate two ideas:

  • Gas used: how much work the transaction needs. This depends on what the transaction does.
  • Gas price: how much you pay per unit of gas. This depends on how busy the network is.

The total fee is roughly gas used multiplied by gas price.

What is gwei

Gas prices are quoted in gwei, a small unit of ether. One gwei equals one billionth of an ether, or 10^-9 ETH. Using gwei avoids writing prices with long strings of zeros.

Gas limit

When you send a transaction, your wallet sets a gas limit: the maximum amount of gas you allow the transaction to use. If the transaction needs more than that, it fails, and the gas already consumed is still paid because the network did the work. Wallets usually estimate a suitable limit automatically.

EIP-1559: base fee and priority fee

In August 2021, the London upgrade introduced EIP-1559, which changed how Ethereum fees work. Since then, the fee per unit of gas has two parts:

  • Base fee: set by the protocol for each block, rising when blocks are fuller than the target and falling when they are emptier. The base fee is burned, meaning it is permanently removed from circulation rather than paid to anyone.
  • Priority fee, often called a tip: an extra amount paid to the validator to encourage them to include your transaction sooner.

Users also set a max fee, the most they are willing to pay per unit of gas. If the base fee plus tip turns out lower, the difference is not charged. This design made fees more predictable for wallets to estimate, although it does not make them cheap when demand is high.

Fees on Bitcoin

Bitcoin does not use gas. A Bitcoin transaction fee depends mainly on the transaction's size in data, not on how much bitcoin is sent. A transaction that spends many small inputs takes more space and costs more than one with a single input, even if the amount is the same. Fees are usually expressed in satoshis per virtual byte.

Miners choose which transactions to include and generally prefer those paying more per byte. Transactions waiting to be confirmed sit in a queue called the mempool. If you pay too little during a busy period, your transaction may wait a long time.

Bitcoin fees go to the miner who includes the transaction. As the block subsidy shrinks with each halving, fees are expected to become a more important part of miner income.

Why fees change so much

  • Demand: popular events, market volatility or a new token launch can fill blocks quickly.
  • Transaction type: complex contract calls on Ethereum use more gas than simple transfers.
  • Network choice: different blockchains have different capacity and fee rules.

Ways people reduce fees

  • Sending transactions when the network is less busy
  • Using layer 2 networks, which bundle many transactions and post them to the main chain together
  • On Bitcoin, combining small inputs when fees are low

Exchange fees are a separate thing. A centralized exchange charges its own trading and withdrawal fees, which are set by the company, not by the blockchain.

Key points

  • Fees pay for network security and protect against spam.
  • On Ethereum, fee equals gas used times gas price, quoted in gwei.
  • Since EIP-1559, the base fee is burned and the tip goes to the validator.
  • Bitcoin fees depend on transaction size, not on the amount sent.