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.
Network & Price Configuration
Gas Cost by Operation
| Operation | Gas | ETH | USD (Mainnet) | USD (Arbitrum) | USD (Base) |
|---|
Custom Gas Calculation
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.
Related Products
on GumroadDeveloper Productivity Bundle
Stop rebuilding the same setup every project. 51 VSCode snippets, 40 Git aliases, 5 Docker Compose stacks, 5 GitHub Actions workflows, 5 README templates, and a dotfiles kit. Set up a professional dev environment in under an hour.
Buy on Gumroad →AI Prompt Engineering Toolkit
58 structured prompt templates for Claude, ChatGPT, and Gemini — organized by use case. Code Review, Debugging, Documentation, Architecture, and 10 model-specific tips. Stop writing prompts from scratch.
Buy on Gumroad →Developer Cheat Sheet Bundle
10 print-ready cheat sheets for the tools developers use every day: Git, Docker, Linux CLI, SQL, Regex, HTTP Status codes, VS Code shortcuts, Bash scripting, jq/JSON, and Markdown.
Buy on Gumroad →You Might Also Need
EVM Calldata Decoder
Decode Ethereum transaction calldata from raw hex. Parse function selectors, decode ABI-encoded arguments for all Solidity types, and analyze transaction input data.
Open free tool →
ABI Encoder/Decoder
Encode and decode Ethereum ABI data. Supports all Solidity types: uint, address, bool, bytes, string, arrays, tuples. Includes abi.encode and encodePacked.
Open free tool →
Blockchain Transaction Fee Calculator
Calculate transaction fees across Ethereum, Arbitrum, Optimism, Base, Polygon, BSC, Avalanche, and Solana. Compare costs for transfers, swaps, and DeFi.
Open free tool →
More Free Tools
Enjoying this tool? Get more like it.
Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.
Unlock AI-Powered Dev Tools
- ⚡ AI Code Review, Doc Generator & SQL Builder
- ⚡ All premium templates & early access
- ⚡ Member discounts on Gumroad products
$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.
MIT licensed · Instant download · No subscription
See what's included → Browse all deals →