Glossary
Gas (Ethereum)
Ethereum's computation-cost unit
By Buğra SözeriPublished Updated
Gas is Ethereum’s unit of computational cost. Every operation the Ethereum Virtual Machine (EVM) can execute — add two numbers, read storage, hash a value, send a transaction — has a defined gas cost. Users pay validators in ETH for that gas, denominated as gas_used × gas_price.
Concrete examples (approximate, post-Cancun upgrade):
- Simple ETH transfer: 21,000 gas (fixed minimum)
- ERC-20 token transfer: ~65,000 gas
- Uniswap V3 swap: ~150,000 gas
- Deploy a basic smart contract: 500,000 - 2,000,000 gas
- Mint an NFT: 80,000 - 200,000 gas
Gas price (denominated in Gwei) varies with network congestion. Each block has a target gas usage; if the previous block used more than the target, gas price rises; less, it falls (the EIP-1559 mechanism, August 2021).
Total fee paid: fee = gas_used × gas_price. A simple transfer at 30 Gwei: 21,000 × 30 = 630,000 Gwei = 0.00063 ETH. At $3,000/ETH that’s about $1.89.
Post-EIP-1559 the gas price has two parts: base fee (set algorithmically, burned permanently) and priority fee (tip to validators, kept by them). The base fee burn is one source of Ethereum’s deflationary pressure — in high-usage periods, more ETH is burned via base fees than is issued in block rewards.
Worked example
You want to mint an NFT on a contract that consumes ~120,000 gas. The wallet recommends a gas limit of 150,000 (25% safety buffer) and shows a base fee of 18 Gwei plus a 1.5 Gwei priority tip. Total max fee: 150,000 × (18 + 1.5) = 2,925,000 Gwei = 0.002925 ETH (~$8.78 at $3,000/ETH). Submit the transaction; it actually consumes 118,400 gas. You pay 118,400 × (18 + 1.5) = 2,308,800 Gwei ≈ $6.93. The unused 31,600 × 19.5 Gwei refund: ~$1.85, returned to your wallet. Of the $6.93 actually paid, the base fee portion 118,400 × 18 = 2,131,200 Gwei (~$6.39) is burned permanently; the priority tip 118,400 × 1.5 = 177,600 Gwei (~$0.53) goes to the validator that included your transaction.
Each EVM opcode has a defined gas cost in the Ethereum Yellow Paper: ADD costs 3 gas, MUL costs 5, SSTORE (writing to persistent storage) costs 20,000 for a new slot and 5,000 for an existing one, SLOAD (reading storage) costs 2,100 after the Berlin hard fork. Smart-contract gas optimisation is largely a study of which opcodes a given Solidity construct compiles into — and developers routinely shave 30-50% off transaction costs by rewriting hot paths to minimise SSTORE operations.
When and why it matters
Gas matters whenever a transaction interacts with the Ethereum mainnet (or a fork like Polygon PoS, BNB Chain — same EVM rules, different price points). The most expensive mistake is setting gas limit too low and watching the transaction revert at 90% completion, paying the full execution cost up to that point. The second is sending during a fee spike — minting a hot NFT or trading during a depeg can cost 10-50× normal rates for the same operation. The mitigation strategies: (1) use a wallet that estimates gas with proper buffers; (2) check gas-price oracles (etherscan.io/gastracker) before non-urgent transactions; (3) use L2 chains for routine activity, reserving mainnet for high-value settlements only; (4) for time-flexible operations, schedule for low-traffic hours (Sundays UTC are typically cheapest). Reference: ethereum.org — Gas and fees.
Gas limit vs gas used — the difference that costs users money: a transaction specifies a gas limit (the maximum the sender is willing to pay for) and the network records gas used (the actual computation cost). If gas used < gas limit, the unused portion refunds to the sender. If gas used would exceed gas limit, the transaction reverts but the sender still pays for everything executed up to the failure point. Setting gas limit too low produces “out of gas” reverts that cost real ETH; setting it too high is harmless but wastes nothing. Wallets typically estimate gas with a 20-30% safety buffer to avoid edge-case reverts.
EIP-4844 (proto-danksharding, March 2024) and the L2 cost collapse: EIP-4844 added a new transaction type for “blobs” — temporary data the L1 doesn’t store but L2 rollups can use as data-availability backing. Blob gas is priced separately from execution gas and is dramatically cheaper. After deployment, Optimism, Arbitrum, and Base saw their per-user transaction fees drop 5-10×. For L2 users, gas pricing now has two components — L2 execution gas (cheap) and the amortised L1 blob cost (also cheap post-4844). Reference: Ethereum Yellow Paper, EIP-1559.
Frequently asked questions
- What is gas in Ethereum?
- Gas is the unit that measures the computational work required to execute operations on the Ethereum network. A simple ETH transfer costs 21,000 gas; complex smart contract interactions cost hundreds of thousands of gas. The total transaction fee is gas used × gas price (in Gwei).
- How is gas calculated in practice?
- After EIP-1559, the fee is: gas used × (base fee + priority fee). If a swap uses 150,000 gas, base fee is 15 Gwei, and you set a 2 Gwei tip, the fee is 150,000 × 17 Gwei = 2,550,000 Gwei = 0.00255 ETH. The base fee is burned; the tip goes to the validator.
- What is the difference between gas limit and gas price?
- Gas limit is the maximum amount of gas you authorise for a transaction — it's a safety cap to prevent runaway contracts from draining your wallet. Gas price (or more precisely, max fee per gas) is what you're willing to pay per unit of gas. The actual cost is gas used × effective gas price.
- Why does Ethereum use gas instead of just charging ETH directly?
- Gas separates the computational cost of an operation from the market price of ETH. The cost in gas of an EVM opcode (e.g., ADD = 3 gas, SSTORE = 20,000 gas) is fixed by the protocol. Only the ETH price of gas fluctuates with network demand, keeping computational pricing predictable.
Related
Published May 16, 2026 · Last reviewed May 31, 2026