Gas Limit

The ceiling on work a transaction or block may use, protecting the network from runaway execution.

Basically

The gas limit caps how much computing work a transaction or block can use on networks such as Ethereum.

Key Takeaways

  • Gas limits cap computation at two levels. You set the transaction gas limit for one transaction, while the block gas limit caps the total computation of all transactions in a block.
  • Running out of gas reverses state changes but still costs you the full fee. This penalty stops attackers from spamming the network with expensive computation for free and complements EIP-1559's base fee burn.
  • Bitcoin's weight units measure data size, unlike Ethereum's gas, which measures computational complexity. CPU cycles, storage reads and writes, and memory expansion all have distinct costs.

What Is Gas Limit?

The gas limit is the maximum amount of gas, or computational effort, that a transaction or block can consume on an EVM-based blockchain like Ethereum. You can think of it as a budget: the sender authorises a certain amount of computation, and execution stops if the budget runs out before the transaction finishes.

Gas limits exist at two distinct levels. You set the transaction gas limit when submitting a transaction; a simple ETH transfer always costs exactly 21,000 gas, so users typically set a limit at or slightly above that number, while complex smart contract interactions require more gas and wallets estimate the appropriate limit automatically. The block gas limit is a network-wide parameter that caps total computation per block, and as of late 2025, Ethereum's block gas limit sits at 60 million gas following the Fusaka upgrade.

Gas limits stop a single buggy or malicious contract from looping forever, consuming infinite resources and halting the network. They make the EVM a bounded computation environment where every operation has a measurable cost.

How It Works

Every EVM opcode has a fixed gas cost. During execution, the EVM tracks a gas counter that starts at the transaction's gas limit and falls with each operation, halting immediately if the counter reaches zero.

Transaction Gas Limit

The sender sets the transaction gas limit when submitting a transaction. This value is the maximum gas the sender authorises, and the actual fee depends on how much gas is consumed.

Setting the gas limit too low causes the transaction to fail with an out-of-gas error. Setting it too high has no direct financial penalty because unused gas is refunded, but your wallet reserves the full amount, calculated as gas limit times max fee per gas, until the transaction confirms.

Block Gas Limit

The block gas limit constrains total computation across all transactions included in a single block. Validators, previously miners under proof of work, determine this value through a signalling mechanism: each block proposer can adjust the limit by up to 1/1024 (~0.1%) from the previous block, with no hard fork required.

Ethereum's block gas limit has increased significantly over time. The network has raised this ceiling as capacity has changed.

Under EIP-1559, the target block usage is 50% of the gas limit, or 30 million gas at the current 60 million limit. The base fee increases when blocks are more than half full and decreases when they are less than half full, creating a dynamic pricing mechanism that adjusts to network demand without requiring you to guess the right gas price.

Per-Transaction Cap

EIP-7825, finalised in the Fusaka upgrade, introduced a per-transaction gas limit cap of 16,777,216 (2^24). No single transaction can consume beyond this threshold even if the block gas limit allows more, which prevents one transaction from monopolising an entire block and stabilises block validation times.

Gas Costs for Common Operations

Different EVM operations consume different amounts of gas. Storage operations are the most expensive because they modify blockchain state permanently.

The cold/warm distinction was introduced by EIP-2929. The first time a transaction accesses an address or storage slot, it pays the higher "cold" cost; subsequent accesses within the same transaction pay the lower "warm" cost, and transactions can use access lists (EIP-2930) to pre-declare which addresses and storage slots they will touch, paying a discounted rate upfront instead of the cold access penalty.

Gas Estimation

Wallets and dApps use the eth_estimateGas JSON-RPC method to determine the appropriate gas limit for a transaction. This method simulates execution against the current blockchain state and performs a binary search to find the minimum gas needed.

Gas estimation has inherent limitations because contract state can change between estimation and actual execution, causing the real gas cost to differ. Wallets typically add a 10-20% buffer above the estimate for this reason; an overly generous buffer wastes nothing because excess gas is refunded, but an insufficient buffer means a failed transaction and lost fees.

What Happens When Gas Runs Out

A transaction that exhausts its gas limit during execution triggers five things in sequence. The sequence describes how the network handles the failed execution and its fee.

Charging for failed transactions is an intentional design choice. Free out-of-gas failures would let attackers flood the network with computationally expensive transactions at no cost, effectively creating a denial-of-service attack, so the fee penalty ensures every computation attempt carries an economic cost regardless of outcome.

Gas Limit vs. Bitcoin Weight Units

Bitcoin uses a different system called weight units to limit block capacity. Ethereum's gas measures computational complexity, while Bitcoin's weight units measure data size.

Bitcoin's block size limit does not account for computational complexity because Bitcoin Script is intentionally non-Turing complete. Ethereum needs gas precisely because the EVM supports arbitrary computation through smart contracts.

Research on EIP-4844 and blob fee markets offers deeper analysis of how different blockchains approach transaction capacity and fee markets. You can use it to compare these approaches further.

Out-of-Gas Failures

The most common risk is setting the gas limit too low. Complex contract interactions, especially those involving multiple nested calls or large storage writes, can consume significantly more gas than estimates predict, and failed transactions still cost the full gas fee, making repeated failures expensive.

Gas Estimation Inaccuracy

Gas estimation via eth_estimateGas simulates against current state, but state can change before the transaction executes. A pending transaction from another user might modify the same contract storage and change the gas profile entirely; DEX trades are particularly susceptible because liquidity pool state changes between estimation and execution can cause gas usage to spike or the transaction to revert.

Block Gas Limit Governance

Raising the block gas limit increases throughput but also increases the hardware requirements for running a full node. Larger blocks take longer to propagate and validate, increasing the risk of chain reorganisations and reducing the number of participants who can afford to run validator nodes, which creates a tension between scalability and decentralisation: a core tradeoff described by the blockchain trilemma.

Layer 2 Alternatives

High gas costs on Ethereum have driven users and developers towards layer-2 solutions that amortise execution costs across many transactions. Rollups batch transactions off-chain and post compressed data to Ethereum, while protocols like Spark take a different approach entirely by operating on Bitcoin, where the UTXO model avoids the gas paradigm altogether.

This glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.

0

← All 1876 glossary terms