What Is Gas in Web3? Definition, Mechanics, and Optimisation
Definition
Gas is the unit of measurement for the computational effort required to execute operations on a blockchain network, most prominently Ethereum and EVM-compatible chains. Every operation a blockchain performs — transferring tokens, executing smart contract functions, deploying contracts, minting NFTs, or casting DAO governance votes — consumes a specific quantity of gas proportional to its computational complexity.
Gas serves two essential functions. It prevents network abuse by attaching a cost to computation, ensuring that infinite loops and wasteful operations cannot consume network resources for free. And it compensates validators (or miners, on proof-of-work chains) for the computational resources they expend processing transactions.
Gas is not a token or asset that users hold. Rather, it is a measurement unit — analogous to kilowatt-hours for electricity — that quantifies computational consumption. Users pay for gas in the blockchain’s native currency (ETH on Ethereum, MATIC on Polygon, and so forth).
How Gas Works
Gas Units and Gas Price
Every Ethereum Virtual Machine (EVM) operation has a fixed gas cost. A simple ETH transfer costs 21,000 gas units. An ERC-20 token transfer costs approximately 65,000 gas units. A complex DeFi swap might consume 200,000-500,000 gas units. And deploying a smart contract can require millions of gas units.
The total transaction fee is calculated as:
Transaction fee = Gas units consumed x Gas price per unit
The gas price — denominated in gwei (one billionth of an ETH) — fluctuates based on network demand. During periods of high activity, users compete for block space by offering higher gas prices, driving up transaction costs. During quiet periods, gas prices fall as competition diminishes.
EIP-1559 Fee Structure
Ethereum’s EIP-1559 upgrade (August 2021) restructured gas pricing into two components.
Base fee — A minimum gas price set algorithmically by the network based on block utilisation. When blocks are more than 50% full, the base fee increases; when less than 50% full, it decreases. The base fee is burned (permanently destroyed), removing ETH from circulation rather than paying it to validators.
Priority fee (tip) — An optional additional payment directly to validators, incentivising them to include the transaction in the next block. Higher tips increase the likelihood of faster inclusion during congested periods.
This structure provides more predictable gas pricing (the base fee adjusts gradually rather than spiking unpredictably) and introduces a deflationary mechanism (base fee burning reduces ETH supply during high-activity periods).
Gas Limit
Each transaction specifies a gas limit — the maximum gas the user is willing to consume. If the transaction completes using less gas than the limit, the unused gas is refunded. If the transaction attempts to consume more gas than the limit, it reverts (fails) and the consumed gas is not refunded — the user pays for the computational work performed even though the transaction ultimately failed.
Setting gas limits requires balance. Too low, and the transaction fails with wasted gas. Too high, and the user’s wallet reserves more value than necessary, though excess is refunded upon completion.
What Drives Gas Costs
Network congestion — More users competing for block space drives up gas prices. Popular NFT mints, DeFi yield opportunities, and market volatility events create demand spikes that can multiply gas costs by ten or more.
Transaction complexity — Simple transfers cost less than complex smart contract interactions. A multi-step DeFi operation involving swaps, lending, and staking across multiple contracts consumes substantially more gas than a single token transfer.
Data storage — Writing data to blockchain storage is the most expensive EVM operation. Transactions that create or modify on-chain state (storing new values, updating mappings, deploying contracts) cost more than transactions that merely read existing state.
Contract efficiency — Smart contract code quality directly affects gas consumption. Well-optimised contracts achieve the same functionality with fewer computational steps, reducing gas costs for users.
Gas on Layer 2 Networks
Layer 2 rollups — Arbitrum, Optimism, Base, zkSync — dramatically reduce gas costs by processing transactions off the Ethereum mainnet whilst posting compressed transaction data back to Ethereum for security.
Layer 2 gas costs are typically 10-100 times lower than Ethereum mainnet equivalents. This reduction makes previously uneconomical operations — micro-transactions, frequent trading, gaming interactions — practical on Ethereum-secured infrastructure.
Layer 2 transactions still pay Ethereum mainnet gas for data posting, creating a cost floor determined by Ethereum gas prices. Recent upgrades (notably EIP-4844, “Proto-Danksharding”) have introduced dedicated data availability mechanisms that further reduce Layer 2 gas costs.
Gas Optimisation Strategies
Timing — Transacting during low-congestion periods (typically weekends, early mornings UTC) reduces gas costs by avoiding peak demand pricing.
Layer 2 migration — Moving activity to Layer 2 networks provides order-of-magnitude gas savings for most DApp interactions.
Transaction batching — Combining multiple operations into single transactions reduces per-operation gas costs by amortising fixed transaction overhead.
Gas tokens and sponsorship — Some protocols and wallets subsidise gas costs for users, absorbing fees to reduce adoption friction. Account abstraction enables gas payment in tokens other than the native chain currency.
Gas mechanics represent both a critical resource management system and a significant barrier to mainstream Web3 adoption. The ongoing evolution of gas markets — through Layer 2 scaling, gas abstraction, and protocol optimisation — is steadily reducing this barrier whilst maintaining the resource pricing that protects network integrity.
Donovan Vanderbilt is a contributing editor at ZUG WEB3, the decentralised protocol intelligence publication of The Vanderbilt Portfolio AG, Zurich. He covers Web3 fundamentals, blockchain economics, and the technical mechanics of decentralised networks.