What is Gas Limit?

1 min read Updated

Gas limit is the maximum amount of gas a user is willing to spend on a transaction — setting an upper bound on computational work to prevent runaway execution and protect against infinite loops.

WHY IT MATTERS

The gas limit serves as a safety valve. Complex contract interactions can consume unpredictable amounts of gas. By setting a limit, you ensure your transaction won't spend more than intended — if execution exceeds the limit, the transaction reverts.

Two levels of gas limit exist: per-transaction (set by the sender) and per-block (set by the protocol, currently ~30M gas on Ethereum). The block gas limit caps the total computation in each block.

Setting gas limits correctly matters: too low and your transaction reverts (but you still pay for gas consumed). Too high and you risk overpaying if gas estimation is wrong. Modern wallets estimate gas automatically.

FREQUENTLY ASKED QUESTIONS

What happens if I set gas limit too low?
Transaction reverts (fails) but you still pay for the gas consumed up to that point. The state changes are rolled back but the ETH spent on gas is gone.
How do I know what gas limit to set?
Wallets estimate automatically using eth_estimateGas. Add a safety margin (10-20%) for contracts with variable execution paths. Simple ETH transfers always cost exactly 21,000 gas.
What's the block gas limit?
The maximum total gas for all transactions in a block (~30M on Ethereum). This limits how much computation can happen per block and creates the fee market when demand exceeds capacity.

FURTHER READING

Enforce policies on every tool call

Intercept is the open-source MCP proxy that enforces YAML policies on AI agent tool calls. No code changes needed.

npx -y @policylayer/intercept
github.com/policylayer/intercept →
// GET IN TOUCH

Have a question or want to learn more? Send us a message.

Message sent.

We'll get back to you soon.