Skip to main content

Smart Contract Gas Estimator

Calculate ETH gas costs for common smart contract operations. Compare costs across Ethereum mainnet and L2 networks at current gas prices.

✓ 16 common operations ✓ Mainnet + L2 comparison ✓ USD cost calculator

Network & Price Configuration

Gas Cost by Operation

Operation Gas ETH USD (Mainnet) USD (Arbitrum) USD (Base)

Custom Gas Calculation

$0.00
per transaction

Frequently Asked Questions

How is gas cost calculated on Ethereum?▼

Transaction cost = gasUsed × gasPrice. Gas price = baseFee + priorityFee (EIP-1559). baseFee is burned by the protocol and fluctuates with demand. priorityFee (tip) goes to the validator. Gas limit is the maximum gas you're willing to spend — unused gas is refunded. Total ETH cost = gasUsed × (baseFee + priorityFee).

What are typical gas costs for common operations?▼

ETH transfer: 21,000 gas. ERC-20 transfer: ~65,000 gas. ERC-20 approve: ~46,000 gas. Uniswap V3 swap: ~130,000-200,000 gas. NFT mint (ERC-721): ~100,000-200,000 gas. Contract deployment: 200,000+ gas depending on bytecode size. Storage write (SSTORE): 20,000 gas. Storage read (SLOAD): 2,100 gas.

How do L2s reduce gas costs?▼

L2s (Arbitrum, Optimism, Base, zkSync) execute transactions off the main Ethereum chain and only post compressed data to L1. This reduces costs 10-100x. Optimistic rollups have ~7-day withdrawal delays but are EVM-equivalent. ZK rollups use validity proofs for instant finality. Most DeFi activity has moved to L2s for cost reasons.

What is the EIP-1559 fee mechanism?▼

EIP-1559 (London upgrade, 2021) replaced the first-price auction with a base fee + tip model. The base fee is algorithmically set by the protocol based on demand and is burned (removed from supply). The tip (priority fee) is optional and goes to validators. This makes fee prediction more reliable and reduces fee overpayment.

How can I optimize smart contract gas usage?▼

Key optimizations: (1) Pack storage slots — multiple small variables in one slot. (2) Use calldata instead of memory for read-only inputs. (3) Cache storage reads in memory variables. (4) Use mappings over arrays for lookups. (5) Avoid dynamic array loops with unbounded size. (6) Use custom errors instead of require strings. (7) Use immutable/constant for deploy-time values.

Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$9/mo after trial · Cancel anytime

Want the full toolkit?

Get DevPlaybook Pro

Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →