Hashtag Web3 Logo

Gas Fee

The transaction fee paid to process and validate operations on a blockchain network, compensating validators or miners for computational resources.

TechnicalBeginner
Ethereum network transaction visualization

Gas fees are payments made to execute transactions or run smart contracts on blockchain networks. The term originated with Ethereum, where "gas" represents the computational effort required to process operations.

Why Gas Fees Exist

Blockchain networks are shared resources with limited capacity. Gas fees serve multiple purposes:

Resource Allocation: Higher fees prioritize transactions during network congestion, ensuring important operations get processed first.

Validator Compensation: Fees reward those who maintain the network—miners in Proof of Work or validators in Proof of Stake.

Spam Prevention: Requiring payment for every operation prevents attackers from flooding networks with frivolous transactions.

How Gas Fees Work on Ethereum

Ethereum gas fees have two components:

Base Fee: Algorithmically determined fee that adjusts based on network congestion, burned (removed from circulation) rather than paid to validators.

Priority Fee (Tip): Optional payment to validators to incentivize faster transaction inclusion. During high congestion, higher tips get processed first.

Total fee = (Base Fee + Priority Fee) × Gas Used

Gas is measured in gwei (1 gwei = 0.000000001 ETH). A simple ETH transfer uses about 21,000 gas units. Complex smart contract interactions might use 200,000+ gas units.

Factors Affecting Gas Costs

Network Congestion: When many users compete for block space, fees rise. During NFT launches or market volatility, fees can spike 10-100x normal levels.

Transaction Complexity: Simple transfers cost less than deploying contracts or executing complex DeFi operations.

Time of Day: Gas tends to be cheaper during off-peak hours when fewer users are transacting.

Chain Choice: Alternative blockchains like Polygon or Arbitrum offer significantly lower fees than Ethereum mainnet.

Gas Optimization

Batch Transactions: Combining multiple operations into one transaction reduces overall costs.

Layer 2 Solutions: Networks like Arbitrum and Optimism bundle transactions off-chain, reducing individual fees to pennies.

Gas Tokens: Some protocols allow "pre-buying" gas during low-fee periods for later use.

Contract Optimization: Developers can write more efficient smart contract code to reduce gas consumption.

Gas Fees Across Blockchains

Different networks handle fees differently:

Bitcoin: Fees based on transaction size in bytes, not computational complexity.

Solana: Extremely low fees (fractions of a cent) but occasional network congestion.

Polygon: Ethereum-compatible with sub-cent transactions.

Binance Smart Chain: Lower fees than Ethereum but more centralized.

EIP-1559: London Hard Fork Changes

Ethereum's August 2021 upgrade fundamentally changed gas fee mechanics. Previously, users bid in a first-price auction. EIP-1559 introduced:

Base Fee: Algorithmically determined minimum fee, adjusted block-by-block. If blocks are >50% full, base fee increases up to 12.5% per block. If <50% full, it decreases. This creates predictable pricing.

Priority Fee (Tip): Added to base fee to incentivize validators. Higher tips during congestion get faster inclusion.

Fee Burning: Base fees are burned (destroyed), making ETH slightly deflationary when network usage is high. Since EIP-1559, millions of ETH have been permanently removed from circulation.

Fee Caps: Users set maxFeePerGas (maximum willing to pay) and maxPriorityFeePerGas (tip). Prevents overpaying if base fee drops before transaction inclusion.

Gas Limit vs Gas Used

Gas Limit: Maximum gas units you're willing to spend. If your transaction uses less, you're refunded the difference. Set too low, and transactions fail (but you still pay for the gas used until failure).

Gas Used: Actual gas consumed by your transaction. Simple ETH transfers always use 21,000 gas. Complex smart contract calls vary based on computation.

Each operation has fixed gas costs:

  • Adding two numbers: 3 gas
  • Multiplying: 5 gas
  • Reading storage: 200-2,100 gas
  • Writing storage: 5,000-20,000 gas
  • Creating contract: 32,000 gas + deployment costs

Historical Gas Price Trends

Gas prices fluctuate wildly based on network activity:

2020 DeFi Summer: Average gas prices hit 400+ gwei during yield farming mania. Simple transactions cost $50-100.

2021 NFT Boom: Bored Ape and other launches pushed gas to 500-1,000+ gwei. Minting NFTs could cost $500+ in gas.

2022 Bear Market: Gas averaged 10-30 gwei. Typical transactions under $5.

2024 Post-Dencun: Introduction of EIP-4844 (Proto-Danksharding) reduced L2 costs dramatically while mainnet gas remained stable.

Tracking tools like Etherscan Gas Tracker, ETH Gas Station, and Blocknative help users time transactions for lower costs.

Layer 2 Solutions and Gas

Ethereum's high gas fees drove development of Layer 2 (L2) scaling solutions:

Optimistic Rollups (Arbitrum, Optimism): Bundle hundreds of transactions off-chain, submitting compressed data to mainnet. Reduces individual transaction costs by 10-50x. Simple transfers cost $0.10-$1, complex DeFi $2-$5.

ZK-Rollups (zkSync, Starknet): Use zero-knowledge proofs for validity. Theoretically more efficient than optimistic rollups. Costs comparable or lower.

EIP-4844 (Proto-Danksharding): March 2024 upgrade added "blob" data storage, reducing L2 data posting costs by 10x. L2 transaction costs dropped to pennies.

State Channels (Lightning Network for Bitcoin): Open channels for unlimited transactions, settling final state on-chain. Near-zero fees but requires channel setup.

L2s inherit Ethereum security while dramatically reducing costs, enabling microtransactions and mainstream applications.

Gas Optimization Techniques for Developers

Storage Optimization: Storage operations are most expensive. Techniques include:

  • Packing multiple values into single storage slots (32 bytes)
  • Using memory instead of storage when possible
  • Deleting unused storage (gets gas refunds)

Loop Optimization: Minimize storage reads/writes in loops. Cache values in memory.

Function Visibility: external functions are cheaper than public for external calls.

Short-Circuit Evaluation: Order conditions to fail fast, avoiding unnecessary computation.

Events vs Storage: Emitting events is much cheaper than storing data, though events aren't readable by contracts.

Batch Operations: Process multiple items in one transaction rather than many transactions.

Proxy Patterns: Deploy minimal proxy contracts pointing to implementation, reducing deployment costs 10x.

Tools like Hardhat Gas Reporter analyze contract gas usage, identifying optimization opportunities.

Gas Tokens (Historical)

CHI and GST2 tokens exploited gas refunds by storing data when gas was cheap, then deleting it during expensive periods to receive refunds. EIP-3529 removed these refunds, making gas tokens obsolete.

Gas Across Different Blockchains

Bitcoin: Fees based on transaction size in bytes, not computation. Typical transaction: 250 bytes. During congestion, fees can exceed $50 but are usually $1-$5.

Solana: Prioritizes throughput, averaging $0.00025 per transaction. Network congestion can cause failed transactions rather than high fees.

Polygon: EVM-compatible Ethereum sidechain. Fees typically $0.01-$0.10. Some congestion during NFT launches.

BNB Chain: Ethereum fork with larger blocks and fewer validators. Fees average $0.10-$0.50.

Avalanche: Subnet architecture allows custom fee structures. C-Chain (EVM) fees typically $0.50-$2.

Cosmos: App-chains set their own fee structures. Typically $0.01-$0.10.

Each blockchain makes tradeoffs between decentralization, security, and transaction costs.

Gas Fee Impact on Application Design

Batch NFT Minting: ERC-721A allows minting multiple NFTs in one transaction for nearly the same gas as one.

Off-Chain Signatures: Applications collect signatures off-chain, submitting only final results on-chain. Reduces user gas burden.

Lazy Minting: NFTs aren't minted until purchased, avoiding upfront creator costs.

Gasless Transactions: Meta-transactions where relayers pay gas, user signs message authorizing action.

L2-First Design: Building on L2s enables features impossible on mainnet due to costs—gaming with frequent microtransactions, social platforms with many interactions.

Career Opportunities

Gas Optimization Engineer ($140k-$350k+): Specialized smart contract developers focused on reducing gas costs. Essential for NFT launches and high-volume applications.

L2 Protocol Developer ($150k-$400k+): Building rollup infrastructure, bridges, and scaling solutions. Cutting-edge cryptography and distributed systems knowledge required.

DevOps Engineer ($120k-$280k): Managing infrastructure for transaction submission, gas price prediction, and MEV protection.

Protocol Economist ($130k-$300k+): Designing fee markets, studying gas economics, modeling protocol incentives.

Blockchain Data Analyst ($80k-$160k): Analyzing gas usage patterns, network congestion, helping projects optimize costs.

Understanding gas mechanics is fundamental for blockchain development and DeFi participation. As Ethereum scales and L2s mature, gas optimization remains critical for user experience and application viability.

Find Gas Fee Jobs

Explore positions at companies working with Gas Fee technology

Browse open roles

Learn More

Read in-depth articles and guides about Web3 careers and technology

Explore the blog