Gas Fees Explained: Why Transactions Cost Money
Estimated read time: 10–12 minutes | Level: Beginner | Topic: Blockchain Basics
On Ethereum since EIP-1559, you set a max fee and a priority tip; the network burns the base fee and the validator earns your tip.
Fees rise with demand and with how much work your transaction does. Save money by transacting off-peak, using Layer 2s, batching actions, and avoiding failed/reverted transactions.
Introduction
Every blockchain transaction whether you’re sending cryptocurrency, swapping tokens on DeFi, or minting an NFT comes with a cost known as a
gas fee. These fees make spamming the network expensive, compensate validators for running nodes, and help allocate limited block space to the highest-value activity. Understanding how gas works helps you time transactions, choose networks wisely, and avoid paying more than you need to.
What Are Gas Fees?
“Gas” measures how much computation and storage a transaction consumes. Every operation in a smart contract (like writing to storage or verifying a signature) has an associated gas cost. You pay fees in the network’s native currency (ETH on Ethereum, for example).
Key Concepts
- Gas Units: A metered amount of computational work. Simple ETH transfers use ~21,000 gas; complex DeFi interactions can use hundreds of thousands.
- Base Fee: The minimum price per gas unit set by the protocol and adjusted block-to-block based on demand (EIP-1559). It is burned (destroyed), not paid to validators.
- Priority Tip: An optional extra you offer to incentivize faster inclusion. This goes to the block proposer/validator.
- Max Fee: The ceiling you’re willing to pay per gas. Your wallet typically expresses this as
maxFeePerGasandmaxPriorityFeePerGas.
How Gas Fees Are Calculated
On post-EIP-1559 Ethereum, the amount you actually pay is:
Total Fee Paid = gasUsed × (baseFeePerGas + effectivePriorityFee)
effectivePriorityFee = min(maxPriorityFeePerGas, maxFeePerGas − baseFeePerGas)
You never pay more than your maxFeePerGas. If the base fee drops while your transaction is pending, the unused headroom is refunded automatically.
Quick example (numbers for illustration):
gasUsed = 21,000
baseFeePerGas = 20 gwei
maxPriorityFeePerGas (tip) = 2 gwei
Total = 21,000 × (20 + 2) gwei = 462,000 gwei = 0.000462 ETH
maxFeePerGas but the base fee is lower, you get the difference back.Gas Limit vs Gas Used
- Gas limit is the maximum gas you allow this transaction to consume. Think of it as a safety cap.
- Gas used is the actual gas the transaction ended up consuming.
If the transaction reverts, you still pay for the computation that ran until the revert, so failed transactions can be costly.
If it runs out of gas (out-of-gas), it fails and typically consumes the full gas limit. Setting a sensible gas limit (your wallet estimates this) helps avoid accidental overpayment or failures.
Why Do Gas Fees Fluctuate?
- Network Congestion: During popular NFT mints, token launches, or market volatility, more users compete for limited block space, pushing fees up.
- Transaction Complexity: Writing to storage, looping over arrays, or verifying signatures costs more gas than simple transfers.
- Protocol Economics: EIP-1559 adjusts the base fee up when blocks are above the target size and down when below, creating a feedback loop that stabilizes demand, but it doesn’t “fix” fees during surges.
- L2 Data Costs: On Layer 2 rollups, part of your fee is paying to post compressed data back to Ethereum. When L1 fees spike, L2s get pricier too (still typically far cheaper than L1).
Layer 2s vs Mainnet: What You Actually Pay
On rollups like Arbitrum, Optimism, or zkSync, your total fee usually has two parts: the execution fee on the L2 (cheap) and the data availability (DA) fee to post your transaction data to L1 (variable).
Net result: swaps that might cost several dollars on mainnet can cost cents on L2, especially when L1 is quiet. If L1 is extremely busy, L2 fees rise but remain lower than L1 in most cases.
How to Save on Gas Fees
- Transact Off-Peak: Use trackers (e.g., Etherscan Gas Tracker) to find cheaper windows often nights/weekends in your region, though this varies.
- Prefer Layer 2s: Do routine swaps, mints, and games on L2; bridge to mainnet only when needed.
- Batch Actions: If a dapp supports batching (or multicall), combine operations into one transaction to save on base overhead.
- Avoid Failed TXs: Use simulation (many wallets and explorers simulate) to catch reverts before you pay.
- Use EIP-1559 Settings Wisely: Reasonable
maxPriorityFeehelps with inclusion without overbidding. Don’t setmaxFeeabsurdly high unless you understand the refund mechanics. - Permit & Allowances: Where supported, permit signatures (EIP-2612) can replace an extra on-chain “approve,” cutting one transaction.
or a 0-ETH self-transfer with a higher fee (cancel). Your wallet likely has buttons for this. The replacement must be attractive enough for validators to prefer it.
Real-World Examples
- Simple Transfer: Alice sends ETH to Bob. Gas used ≈ 21,000. If base fee is 18 gwei and Alice tips 1.5 gwei, cost ≈
21,000 × 19.5 gwei= 409,500 gwei = 0.0004095 ETH. - NFT Mint Rush: A hyped mint causes a fee spike. Base fee doubles in minutes. Savvy minters either (a) wait until the rush subsides, (b) mint on an L2 version if offered, or (c) set a sensible tip and let their wallet handle dynamic inclusion rather than wildly overpaying.
- DeFi Swap on L2: The same swap that costs $12 on mainnet costs $0.20 on a rollup during moderate L1 fees, because only compact data gets posted back to L1.
Common Myths About Gas Fees
- Myth: “Validators set fees however they want.”
Fact: The base fee is algorithmic. Validators only receive the tip; they don’t control the base fee. - Myth: “Setting a higher fee guarantees success.”
Fact: It increases priority, but if the transaction would revert (bad parameters, insufficient output), you’ll pay gas and still fail. - Myth: “A higher gas limit means I’ll pay more.”
Fact: You pay for gas used, not the limit (except when OOG). The limit is a cap, not a price. - Myth: “Gas tokens can cut my costs.”
Fact: Refund mechanics changed (e.g., EIP-3529), making old gas-token strategies ineffective.
Practical Tips & Gotchas
- Slippage & Deadlines: For swaps, set realistic slippage and short deadlines. Reverts from too-tight slippage still burn gas.
- Approvals: Unlimited approvals save one transaction now but may cost more later if you must revoke; weigh convenience vs. security (and fees).
- Wallet UX: Prefer wallets that show human-readable calls, simulate outcomes, and suggest fair tips. Double-check on-device screens for hardware wallets.
- Bridging: Bridges charge their own fees and often pay L1 data costs; sometimes native L2 on-ramps are cheaper than bridging from mainnet.
Key Takeaways
- Gas prices scarce block space and compensates validators; on Ethereum, base fees are burned and tips go to proposers.
- You control your maximum cost (
maxFeePerGas) and how much you tip (maxPriorityFeePerGas); unused headroom is refunded. - Fees vary with congestion and with how much work your transaction performs.
- Save by using Layer 2s, transacting off-peak, batching actions, and avoiding failed transactions via simulation.
Further Learning Resources
