Gas Limit
The maximum amount of gas a transaction is permitted to consume before execution stops.Definition
The maximum amount of gas a transaction is permitted to consume before execution stops.Why it matters
Transaction and fee concepts explain how users submit work to a blockchain and how network resources are priced.How it works
Before sending a transaction, the wallet calculates an estimate of the required gas. The user or wallet sets a limit higher than this estimate to account for potential variations. If the transaction finishes before reaching the limit, the user only pays for the amount actually used; if it hits the limit, the transaction fails.Real-world example
If you are minting an NFT, your wallet might suggest a gas limit of 200,000. If the contract only needs 150,000 to succeed, your transaction goes through and you pay for 150,000.Advantages
- Prevents infinite execution loops
- Protects user funds from errors
- Provides predictable resource usage caps
Limitations
- Transaction fails if set too low
- Can lead to wasted gas if set too high
- Requires estimation tools
Common misconceptions
- Many think a higher gas limit makes the transaction faster, but it only prevents the transaction from failing early.
- Some believe the gas limit is the total fee, but the fee is calculated using the price multiplied by the used gas.
Related knowledge
- Blockchain — term
- Cryptography — term
- Web3 — term
Canonical knowledge ID:
glossary:gas-limit