Pay for the code you load
10,100 gas
A cold access to any contract today, whether it is 1 byte or 128 KiB.
base + per word
The proposed charge for a cold code load, by code size.
TBD
All three new constants. Benchmarking is pending.
MIP-20 is a Draft and is not active on any network. It replaces the flat price for loading contract code with one that grows with code size. The spec has not set the constants yet.
The information on this page should not be quoted. Please refer to MIP-20 for the authoritative spec.
What counts as loading code
Each of these loads the code of one address. The charge applies when that code hasn't been loaded earlier in the transaction.
CALL, CALLCODE, DELEGATECALL, STATICCALL
Load the code at the call's address. If it holds an EIP-7702 delegation indicator, the delegation target's code is loaded instead.
EXTCODECOPY
Loads code when size is non-zero and the offset is inside the code. It does not follow delegation indicators. A copy that overlaps the code at all is charged for the whole code.
Transaction to address
Its code is charged at the start of execution, from the gas left after intrinsic gas. Nothing is charged for this today.
EXTCODESIZE, EXTCODEHASH, BALANCE
Not code loads. They pay only the account access cost, whatever the code size.
Empty code, precompiles
No code is loaded, so there is no charge.
G_code = CODE_LOAD_BASE_COST + CODE_LOAD_WORD_COST × ceil(code size / 32)
A separate warm set for code
Warm accounts and warm code are tracked separately. Warm code is keyed by code hash.
Keyed by code hash
Addresses with identical code share one entry. After the first load, calls to the others pay no code charge. The spec's example is factory-deployed pools called in a multi-hop swap.
Separate from accounts
If warming an account also warmed its code, a BALANCE followed by a CALL would load the code for free.
New contracts start warm
The creator already has the deployed code in hand.
Access lists don't warm code
Their price is fixed at validation and can't depend on code size.
Rolled back on revert
Entries added in a frame that reverts or halts are removed.
The set starts empty in every transaction.
Who this affects
Contract developers
Cost follows code size
Cold calls and EXTCODECOPY are charged by the size of the code. The spec says small contracts may get cheaper to load and large ones more expensive, depending on the final constants.
Relayers and fixed gas budgets
Hard-coded gas can run out
A transaction to a contract pays a new charge at the start of execution. Budgets that cover nested code loads are affected. Gas estimation accounts for the new costs.
Data contracts
Reads are charged by the whole contract
Contracts that store data as code and read it with EXTCODECOPY pay according to the size of the data contract.
COLD_ACCOUNT_ACCESS_COST, CODE_LOAD_BASE_COST and CODE_LOAD_WORD_COST are all TBD. Test cases and the reference implementation are marked TODO. If a cold call ends up below the 2,300 gas stipend, the spec plans to discuss the effect on contracts that rely on the stipend.
Continue the discussion on Monad Forum
Questions, feedback, or a better idea? Weigh in on the forum thread.
Open forum thread