Solidity Gas Limit Estimator

Estimate gas for common EVM operations and Solidity patterns

Add EVM opcodes and common Solidity patterns — SSTORE, SLOAD, transfer, mapping update, event emission, array push, contract call — with quantities to compute total estimated gas. Helps developers set accurate gas limits and find high-gas hotspots before deployment. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

Where do these gas costs come from?

The figures follow the post-Berlin/London EVM gas schedule from the Ethereum Yellow Paper and EIP-2929. For example a cold SLOAD costs 2,100 gas, a warm SLOAD 100, and setting a storage slot from zero (SSTORE) costs 22,100 gas. Real costs vary with access lists and warm/cold state.

The Solidity Gas Limit Estimator lets you build up an estimate of how much gas a function will consume by listing the EVM operations it performs. It uses the post-Berlin/London gas schedule so you can set realistic gas limits and spot the operations that dominate your cost before you deploy.

Why gas estimation matters before deployment

Setting the gas limit too low causes a transaction to revert out of gas — the user pays the gas consumed up to the failure point and still gets no result. Setting it far too high does not cause a failure, but the frontend or API call needs a realistic limit to avoid confusing users and to catch runaway logic. Two-pass gas estimation (estimate here, confirm with eth_estimateGas against a fork, then add a buffer) is the standard pre-deployment workflow.

How it works

Each EVM opcode has a fixed gas cost defined by the Ethereum Yellow Paper and later EIPs, most recently updated by the Berlin hard fork (EIP-2929, which introduced the warm/cold distinction for storage access). The estimator multiplies the cost of each operation by how many times your function runs it, then adds the mandatory 21,000-gas base transaction cost:

total = 21000 + Σ (opcode gas cost × count)

Key costs in the built-in table (post-Berlin/London EIP-2929 schedule):

OperationGas costNotes
SSTORE (zero → non-zero)22,100Most expensive common write
SSTORE (non-zero → non-zero)5,000Update an existing slot
SSTORE (non-zero → zero)5,000With a 4,800 refund
SLOAD (cold slot)2,100First access this transaction
SLOAD (warm slot)100Already accessed this transaction
ERC-20 transfer (typical)~50,000Two SSTOREs + event
LOG (event emission)~1,125 + 8/bytePlus topic and data costs
External CALL (cold)~2,600 + gas forwardedCALL to a new address
ADD, MUL, arithmetic3–5Negligible individually
Base transaction21,000Every transaction, before code

Setting a safe gas limit

Because real gas depends on warm/cold access patterns, the exact code path taken at runtime, and calldata size, the tool adds a safety buffer on top of the raw total. Use the suggested limit as your transaction gas parameter.

The breakdown sorts operations by their total gas contribution, so the biggest consumers rise to the top. Storage writes almost always dominate. Practical optimisation advice:

  • Pack state variables. Multiple small values in one 256-bit slot share one SSTORE write instead of paying 22,100 per variable.
  • Use memory for intermediate state. MSTORE costs only 3 gas; SSTORE costs thousands. Accumulate in memory and write to storage once at the end.
  • Warm slots are cheap on subsequent reads. If you read the same slot twice in one transaction, the first access is cold (2,100) and the second is warm (100).
  • Avoid storage in loops. A loop over N items with one SSTORE each costs 22,100 × N for cold writes. Consider batching state updates outside the loop.

Always confirm the final number with eth_estimateGas against a local fork or testnet run before deploying to mainnet. This tool is a planning estimate — real gas varies by call path and transaction context.