Understanding Gas Fees: The Complete Guide to Transaction Costs in Crypto
Every transaction on a blockchain costs something. Whether you're swapping tokens, minting an NFT, deploying a smart contract, or simply sending ETH to another wallet, you pay a fee to the network for processing that transaction. These fees are commonly called "gas fees," and understanding how they work is fundamental to operating in crypto, because they directly affect how much it costs to do anything on-chain.
This guide explains what gas actually is, how gas pricing works on Ethereum (and how it changed after EIP-1559), how gas differs across Layer 1s and Layer 2s, and practical considerations for managing transaction costs.
What Is "Gas" and Why Does It Exist?
Gas is a unit of measurement for the computational work required to execute a transaction or smart contract operation on a blockchain. The term originates from Ethereum, but the concept exists on most programmable blockchains (often under different names).
Why do gas fees exist? Two primary reasons:
Spam prevention: Without fees, an attacker could flood the network with millions of transactions for free, overwhelming validators and making the chain unusable. Gas fees create an economic cost to using the network, which deters spam.
Validator compensation: The computers that process and validate transactions need incentives. Gas fees are how validators (or miners, on proof-of-work chains) get paid for the computational resources they contribute.
Different operations require different amounts of gas. A simple ETH transfer (just moving tokens from one address to another) requires relatively little computation. A complex smart contract interaction, like a multi-hop swap on a DEX or a batch operation on a yield farming protocol, requires much more computation and therefore costs more gas.
How Gas Works on Ethereum
Before EIP-1559 (The Old Model)
Originally, Ethereum used a simple auction model for gas. Users would set a gas price (in gwei, a tiny denomination of ETH), and miners would prioritize transactions with higher gas prices. This created a first-price auction where users had to guess how much to bid, often overpaying or having transactions stuck in the mempool when they bid too low.
After EIP-1559 (The Current Model)
In August 2021, Ethereum's London upgrade introduced EIP-1559, which fundamentally changed how gas fees work:
Base fee: Each block has a protocol-determined base fee that adjusts automatically based on network congestion. When blocks are more than 50% full, the base fee increases. When blocks are less than 50% full, it decreases. This creates a more predictable fee market.
Priority fee (tip): Users can add an optional priority fee (tip) on top of the base fee to incentivize validators to include their transaction sooner. During high congestion, a higher tip gets you faster inclusion.
Fee burning: The base fee is burned (destroyed) rather than paid to validators. Only the priority fee goes to validators. This makes ETH slightly deflationary during periods of high network usage, more ETH is burned in fees than is issued as block rewards.
So the total gas cost for a transaction is: Gas Units Used × (Base Fee + Priority Fee)
For example, a standard ETH transfer uses 21,000 gas units. If the base fee is 20 gwei and the priority fee is 2 gwei, the total cost is 21,000 × 22 gwei = 462,000 gwei = 0.000462 ETH.
Why Gas Prices Fluctuate
Gas prices on Ethereum are driven by supply and demand:
- Supply: Each block has a target size (15 million gas) and a maximum size (30 million gas). This is the supply of block space.
- Demand: The number of pending transactions waiting to be included. During NFT mints, token launches, or market volatility, demand surges and prices spike.
Gas fees on Ethereum have ranged from under $0.50 during quiet periods to over $100 (or even $500+) during extreme congestion events. This volatility is one of the main reasons Layer 2 solutions were developed.
Gas on Layer 2 Networks
Layer 2 networks (Arbitrum, Optimism, Base, zkSync, Polygon zkEVM, etc.) are built on top of Ethereum and inherit its security, but they process transactions off the main chain, resulting in dramatically lower fees.
How L2 Gas Fees Work
L2 transaction costs have two components:
- L2 execution fee: The cost of processing the transaction on the L2 itself. This is typically very cheap, fractions of a cent, because L2s have much higher throughput and lower congestion than Ethereum mainnet.
- L1 data fee: L2s post transaction data back to Ethereum mainnet (for security). This "data posting" cost is passed on to users and is usually the larger portion of the L2 fee. After Ethereum's Dencun upgrade (March 2024) introduced "blobs" (EIP-4844), this L1 data cost dropped dramatically — by 10-100x on most L2s.
In practice, most L2 transactions now cost between $0.01 and $0.10, compared to $1-$50+ on Ethereum mainnet for the same operations. This is why much of DeFi activity has migrated to L2s.
Different L2s, Different Fee Profiles
Not all L2s have identical fee structures:
- Optimistic rollups (Arbitrum, Optimism, Base): Generally very cheap for execution, with the L1 data fee being the main cost component. Post-Dencun, most transactions are well under $0.10.
- ZK rollups (zkSync, Polygon zkEVM, Scroll): Can have slightly different fee dynamics because they generate validity proofs (which has its own computational cost) instead of relying on fraud proofs. The proof generation cost is amortized across many transactions.
Gas on Other Layer 1 Chains
Different L1 blockchains have their own fee models:
Solana: Uses a different fee model with very low base fees (typically fractions of a cent) and optional "priority fees" for faster inclusion. Solana's high throughput keeps fees low, but during extreme congestion (popular NFT mints, etc.), priority fees can spike significantly.
Avalanche: Uses a similar gas model to Ethereum but with its own fee dynamics on the C-Chain. Fees tend to be lower than Ethereum mainnet but higher than L2s.
BNB Chain: Relatively low and stable fees due to centralized validator set and high throughput. Typically $0.05-$0.30 per transaction.
What Affects Your Gas Costs
Several factors determine how much you actually pay:
- Transaction complexity: A simple token transfer costs much less than a complex DeFi operation. A Uniswap V3 swap uses roughly 130,000-200,000 gas units versus 21,000 for a basic ETH transfer.
- Network congestion: More pending transactions = higher base fees. Gas prices are lowest during off-peak hours (typically weekends and late night/early morning UTC).
- Which chain you're on: The same swap that costs $15 on Ethereum mainnet might cost $0.03 on Arbitrum.
- Token approvals: The first time you interact with a DeFi protocol, you often need to approve the token contract. This is a separate transaction with its own gas cost. Infinite approvals (approve unlimited spending) save on future approval gas but carry security tradeoffs.
- Failed transactions: If a transaction fails (e.g., slippage too low, contract reverts), you still pay the gas. The computation was performed; the network doesn't refund you just because the outcome wasn't what you wanted.
Practical Tips for Managing Gas
Some general approaches people use to manage gas costs:
- Time your transactions: Gas prices on Ethereum follow patterns, they tend to be lower on weekends and during off-peak hours. Tools like Etherscan's gas tracker show current and historical gas prices.
- Use L2s for regular DeFi activity: For everyday swaps, lending, and farming, L2s offer the same protocols at a fraction of the gas cost.
- Batch operations when possible: Some protocols allow batching multiple operations into a single transaction, reducing total gas overhead.
- Set appropriate gas limits: Most wallets auto-estimate gas, but understanding the settings (max fee, priority fee) helps you avoid both overpaying and stuck transactions.
- Use aggregators: DEX aggregators and transaction bundlers can sometimes find more gas-efficient routes for complex operations.
The Bigger Picture: Where Gas Fees Are Heading
The long-term trend in the Ethereum ecosystem is toward dramatically lower gas costs for end users. EIP-4844 (blobs) already cut L2 fees by orders of magnitude. Future upgrades like full danksharding aim to further increase data availability, which should continue pushing L2 fees down.
The vision is an ecosystem where most user activity happens on L2s with sub-cent fees, while Ethereum mainnet serves as the security and settlement layer. Gas fees on L1 would still exist and could be high, but most users would rarely interact with L1 directly, their transactions would be batched and settled by L2 sequencers.
The Bottom Line
Gas fees are the cost of using decentralized networks. They compensate the validators who secure the network and prevent spam. On Ethereum, EIP-1559 brought more predictable pricing with its base fee and priority fee model. And the Layer 2 ecosystem has dramatically reduced what users actually pay for most transactions.
Understanding gas is practical knowledge: it affects when you transact, which chain you use, and how much each DeFi operation actually costs. As the ecosystem matures, fees will continue to decrease — but they'll always exist in some form, because computation and block space are finite resources.
About Portals.fi: Portals.fi is the DeFi Super App. A one-click gateway to the entire on-chain economy. Powered by real-time data and seamless execution, Portals.fi connects traders to over 20 million assets, thousands of protocols, and every major blockchain.
Disclaimer: The content of this blog is for informational purposes only. It is not investment advice. Please do your own research and consult with a qualified financial advisor before making any investment decisions. DeFi investments carry significant risks, and past performance does not guarantee future results. More details here.
Portals.fi Blog Newsletter
Join the newsletter to receive the latest updates in your inbox.