What is Gas Limit?
How it works
On Ethereum, each operation in the Ethereum Virtual Machine (EVM) costs a predefined amount of gas. A simple ETH transfer requires exactly 21,000 gas. Smart contract executions—like token swaps or lending operations—cost more, depending on the number and complexity of opcodes. The user sets a gas limit when submitting a transaction; if the actual gas used is less than the limit, the excess is refunded (except during a revert). Miners select transactions based on priority fees and include them in blocks.
Each block on Ethereum has a block gas limit, which caps the total gas allowed in that block. This limit is not fixed; validators (miners before the Merge) can signal to gradually increase or decrease the block gas target. For example, the London upgrade (EIP-1559, August 2021) introduced variable-sized blocks with a target of 15 million gas and a maximum of 30 million, allowing more transactions per block during periods of high demand. This parameter influences network throughput and congestion, as a higher limit permits more complex transactions but also increases block propagation time.
Gas limit is distinct from gas price (or priority fee under EIP-1559). The total fee paid equals gas used multiplied by gas price, but the gas limit times gas price represents the maximum fee the user authorizes. Setting a higher gas limit does not make a transaction faster—speed is determined by the gas price bid. However, a limit that is too low will cause the transaction to fail, with all consumed gas still forfeited to the validator.
Why it matters
Gas limit gives users control over their transaction costs and protects against runaway resource consumption. Without it, malicious or buggy smart contracts could deplete a user's balance. By capping the computational work, the gas limit ensures that network resources are allocated predictably and fairly. Accurate estimation is critical: too low wastes gas on failures, while unnecessarily high limits may pre-allocate more ETH than needed. Tools like MetaMask automatically estimate limits, but advanced users can fine-tune them for complex contract interactions to optimize costs.
Real-world examples
On Ethereum, a standard ETH transfer uses a gas limit of 21,000, a fixed cost since the Frontier launch. ERC-20 token transfers require higher limits, often around 50,000–100,000 gas, depending on token logic. Decentralized exchange swaps on Uniswap or lending protocols like Aave typically require 150,000–400,000 gas for complex operations. During network congestion, such as the CryptoKitties craze in 2017, users raised gas limits to ensure transactions were processed, though higher limits did not guarantee faster inclusion without adequate gas prices.
FAQ
What happens if my gas limit is too low on Ethereum?
The transaction fails and reverts, but all gas consumed up to the failure point is still deducted from your account. You lose the fee without achieving the intended outcome.
How do I determine the correct gas limit for a smart contract interaction?
Most wallets like MetaMask provide an estimate based on the transaction details. For advanced control, you can check the gas usage of similar transactions on Etherscan or use tools like the Gas API from Infura.
Does a higher gas limit speed up my transaction?
No. Transaction speed depends on the gas price (or priority fee under EIP-1559), not the gas limit. A higher limit only allows more computation; a competitive fee ensures a validator includes it quickly.
Related terms
Go deeper
Browse the complete crypto glossary to explore related terms and concepts.
Browse Glossary