Gas Limit
In simple terms
The gas limit is a spending cap on computing work. Setting it too low makes the transaction run out partway and fail, and you still pay for the work that was done.
Definition
The maximum amount of computation a transaction is authorised to consume before it is stopped.
In depth
Every operation in a smart-contract virtual machine has a fixed gas cost, and the gas limit bounds the total the transaction may consume. Exceeding it triggers an out-of-gas exception: state changes revert, but the gas consumed is not refunded, since validators performed the work. The limit is separate from the gas price, which is what each unit costs; the maximum fee is the product of the two. A simple transfer has a well-known fixed cost, while a contract interaction is estimated by simulation and can be wrong if state changes between estimate and execution.
How does Gas Limit work?
The wallet simulates the transaction against current state, estimates the gas required, and adds a buffer. The user signs a limit and a price. During execution the network meters each operation until the work completes or the limit is reached. Unused gas below the limit is not charged, so a generous limit costs nothing extra when the transaction succeeds — which is why raising the limit is safe and raising the price is what actually costs more.
An example
A plain ETH transfer uses an illustrative 21,000 gas. A token swap through a contract might use 150,000 or more, and the wallet sets the limit above the estimate. If the pool state shifts before it executes and the real cost exceeds the limit, the transaction reverts and the fee for the attempted work is still charged.
Figures are illustrative only.
What beginners get wrong
- Confusing the gas limit with the fee. The limit is a cap on work; the price per unit is what determines cost.
- Lowering the limit to save money. It does not save anything on a successful transaction and causes an expensive failure on an unsuccessful one.
- Assuming a reverted transaction is free. The network performed the computation and charges for it.
Related terms
Part of
How does a blockchain transaction actually work? — the subject page for blockchain mechanics, with all 15 of its definitions in one place.
Educational only — not financial advice.
