Gas Numbers Every Solidity Dev Should Know

Created by dd0sxx for Macro

Key:

Opcode gas numbers were sourced from the official Ethereum Docs, and contract-calls were sourced from Etherscan.io and converted into gas units using Wolfram Alpha for calculations.

Inspired by Norvig's Latency Numbers, and a post in the Macro discord from a student named Justin Phu, who suggested someone make a version with gas numbers for popular calls and opcodes.

OPCODES

ADD: 3
BALANCE (warm): 100
BALANCE (cold): 2,600
CALLDATACOPY: 7
MSTORE: 3
MLOAD: 3
TIMESTAMP: 2
ADDRESS: 2
LOG0: 632
LOG4: 2,132
SSTORE (clean: zero to nonzero): 22,100
SSTORE (clean: nonzero to nonzero): 5,000
SSTORE (clean: nonzero to zero): 5,000 (refund: 4,800)
SSTORE (dirty: zero to nonzero): 20,000
SSTORE (dirty: nonzero to nonzero): 2,900
SSTORE (dirty: nonzero to zero): 2,900 (refund: 4,800)
SLOAD (cold): 2,100
SLOAD (warm): 100
CALL (no-value, warm): 100
CALL (no-value, cold): 2,600
CALL (no-value, new-address): 25,000
CALL (value, cold): 11,600
CALL (value, warm): 9,100
CALL (value, new-address): 34,000
CREATE: 32,000

CONTRACT CALLS

ERC20::Transfer: 64,883
ERC721::Transfer: 84,663
Uniswap V3::Swap: 184,361
Uniswap V2::Swap: 152,711
SushiSwap::Swap: 140,843
Curve::Swap: 749,314
Balancer::Swap: 196,230
1inch::Swap: 141,634
CoW Protocol::Swap: 343,007
OpenSea::Sale: 202,164
SuperRare::Sale: 130,556
Rarible::Sale: 245,288
LooksRare::Sale: 326,391
ENS::Register Domain: 266,651
Gnosis Safe::Create Multisig: 288,015
Arbitrum::Deposit: 90,994
Optimism::Deposit: 150,733
Polygon::Deposit: 149,151
Beacon Chain::Deposit: 53,014
Tornado.Cash::Deposit: 1,012,400
Tornado.Cash::Withdraw: 360,414
dYdX::Borrow: 174,075
MakerDAO::Borrow: 223,023
Compound::Collect: 1,237,520
Compound::Borrow: 339,842
Compound::Repay: 112,358
Aave::Borrow: 318,478
Aave::Repay: 199,395
Lido::Stake: 82,686
Yearn Finance::Deposit: 216,011
Hop Protocol::Bridge: 121,457
Multichain::Bridge: 57,761
Across Protocol::Bridge: 120,666
Synapse::Bridge: 107,610

Something missing from this page? Make an issue or PR on our github repo 🤖