Module 3: How Blockchains and Transactions Work
Gas and Fees on Ethereum
Chapter 2 of 13 · about 6 minutes
2.1 Why did this cost $46?
On a quiet Sunday morning, Mint swapped tokens on Ethereum mainnet and paid about $1 in fees. The following Wednesday, during a big market move, the same swap cost about $46.
"Same swap, same app, same amount," Mint said. "Why would the fee be forty times higher?"
"Because the fee isn't a price for the swap," said Hash. "It's a price for space in a block, and that price changes every 12 seconds depending on how many people want it."
Module 1, Chapter 4 introduced gas as the fuel for Ethereum. This chapter explains exactly how the fee is calculated, so you can predict it, compare it, and avoid overpaying.
2.2 Two separate ideas: gas units and gas price
The fee depends on two numbers multiplied together.
Gas used is how much computation your transaction needs. It depends on what you're doing, not on the network's busyness. A simple ETH transfer always uses exactly 21,000 gas. A token transfer uses more. A swap uses more again.
Gas price is how much you pay for each unit of gas. It's measured in gwei, where 1 gwei is one billionth of an ETH (0.000000001 ETH). This part depends on demand.
Fee = gas used × gas price
Think of a taxi. The distance of the trip is the gas used. The price per kilometre is the gas price. A longer trip costs more, and so does surge pricing during rush hour. Mint's Sunday and Wednesday swaps were the same distance. Wednesday just had surge pricing.
| Action | Typical gas used |
|---|---|
| Send ETH | 21,000 |
| Send a token | ~45,000 to 65,000 |
| Approve a token | ~45,000 |
| Swap on a decentralised exchange | ~120,000 to 200,000 |
| Complex DeFi interactions | 200,000 and up |
These are typical ranges. The exact amount depends on the specific contract and what it needs to do.
2.3 Base fee and priority fee
Since an upgrade in August 2021, known as EIP-1559, Ethereum's gas price has two parts.
The base fee is set automatically by the network for each block. Every block has a target size. If the previous block was more than half full, the base fee rises, by up to 12.5% per block. If it was less than half full, the base fee falls. Everyone pays the same base fee in a given block. And importantly, the base fee is burned, permanently destroyed, rather than paid to anyone. This is the fee burn mentioned in Module 1, Chapter 4.
The priority fee, also called the tip, is an extra amount you add to encourage block producers to include your transaction. It goes to the validator. When the network is calm, a tiny tip is enough. When it's busy, people raise their tips to get ahead in the queue.
Fee = gas used × (base fee + priority fee)
Chapter 2 · How an Ethereum fee is built
The fee equals gas used times the sum of base fee and priority fee. The base fee is burned and adjusts up or down with network demand. The priority fee is a tip paid to the validator. The max fee sets a ceiling, and any difference above the base fee plus tip is refunded.
2.4 A worked example
Let's calculate Mint's fees, using illustrative numbers and an ETH price of $3,000.
Quiet morning: base fee 1.5 gwei, tip 1 gwei.
| Action | Gas used | Gas price (gwei) | Fee in gwei | Fee in ETH | Fee in USD |
|---|---|---|---|---|---|
| Send ETH | 21,000 | 2.5 | 52,500 | 0.0000525 | ~$0.16 |
| Swap | 150,000 | 2.5 | 375,000 | 0.000375 | ~$1.13 |
Busy market: base fee 100 gwei, tip 2 gwei.
| Action | Gas used | Gas price (gwei) | Fee in gwei | Fee in ETH | Fee in USD |
|---|---|---|---|---|---|
| Swap | 150,000 | 102 | 15,300,000 | 0.0153 | ~$45.90 |
Same swap, about forty times the cost, purely because the base fee rose with demand. A base fee of 100 gwei is a stress spike, and during extreme events base fees have gone far higher still. On ordinary days in 2025 and 2026, especially since much activity moved to Layer 2 networks, mainnet base fees are often under 2 gwei.
Notice something else: the fee doesn't depend on the amount you send. Sending $10 of ETH and $10 million of ETH costs exactly the same gas. That's why small transactions on mainnet can be uneconomical during busy periods, and why Layer 2 networks matter so much (Chapter 8).
2.5 Max fee and gas limit
When your wallet prepares a transaction, it sets two safety caps.
The max fee per gas is the most you're willing to pay per unit of gas. Because the base fee can rise between the moment you sign and the moment your transaction is included, wallets usually set the max fee comfortably above the current base fee. You only pay the actual base fee plus your tip. The unused difference stays in your wallet.
The gas limit is the maximum gas units your transaction may use. Wallets estimate this automatically. If a transaction runs out of gas before finishing, it fails, and the gas used is still charged.
| Setting | What it protects against | If set too low |
|---|---|---|
| Max fee per gas | Paying far more than expected if fees spike | Transaction waits until the base fee falls below it |
| Priority fee (tip) | Overpaying for priority when it's not needed | Transaction may be included slowly when the network is busy |
| Gas limit | A transaction using unexpected amounts of computation | Transaction fails with "out of gas," and you still pay |
"Should I ever change these?" Mint asked.
"Usually, no," said Hash. "The wallet's estimates are good. The main time to adjust is when you're not in a hurry and want to save money, or when you're stuck and need to speed up, which is Chapter 4."
2.6 Saving on gas
A few practical ways to pay less:
Time your transactions. Fees are often lower during quieter periods. Many wallets and gas trackers show current and historical gas prices.
Use Layer 2 networks for frequent or smaller transactions. Fees are usually a small fraction of mainnet (Chapter 8).
Batch when possible. Smart accounts can combine several actions, like approve and swap, into one transaction (Module 2, Chapter 13).
Avoid unnecessary transactions. Each approval, claim, and transfer has a cost. Consolidate where it makes sense.
Don't panic during spikes. If a transaction isn't urgent, waiting an hour can cut the cost dramatically.
2.7 Gas on other networks
Most EVM-compatible networks use the same concept of gas units and gas price, though actual prices vary enormously. Layer 2 networks add a second component: the cost of posting their data to Ethereum, which Chapter 8 explains. Non-EVM blockchains use their own fee systems, but the core idea, paying for limited block space, is nearly universal.
2.8 Try it yourself
Open a gas tracker for Ethereum mainnet. Note the current base fee and suggested priority fee. Using this chapter's formula, calculate what a simple ETH transfer and a 150,000-gas swap would cost right now, in ETH and in your local currency.
Then look up a recent transaction on a block explorer and find the "gas used," "base fee," "priority fee," and "burnt fees" fields. Check that the numbers multiply out as you'd expect.
Key takeaways from this chapter
- Fees equal gas used multiplied by gas price. Gas used depends on the action; gas price depends on demand.
- A simple ETH transfer uses 21,000 gas. Swaps and DeFi actions use much more.
- Gas price is made up of a base fee, which adjusts automatically and is burned, and a priority fee, which goes to validators.
- Fees don't depend on the amount sent, so small transactions can be expensive in busy periods.
- Max fee caps what you'll pay per unit of gas; gas limit caps how much computation you allow.
- Failed transactions still pay for gas used.
- Save on gas by timing transactions, using Layer 2 networks, batching, and avoiding unnecessary steps.