Turning an EOA into a contract under reserve rules

0xA7 SETCODEFROM

From EIP-8298. Sets the current account's code to that of another deployed account.

k = 3 blocks

How long a migrated account stays under the reserve balance check.

MIP-4 + MIP-23

It builds on reserve balance introspection and configurable reserves.

MIP-19 is a Draft and is not active on any network. It adopts SETCODEFROM and adds rules so an account that swaps its delegation for regular code can't slip out of Monad's reserve balance check.

The information on this page should not be quoted. Please refer to MIP-19 for the authoritative spec.

Why Monad needs extra rules

EIP-8298 lets an account replace its code. On Monad that collides with how consensus budgets gas.

  • Consensus lags

    Consensus budgets block n against the state at the end of block n − 3. An account that adopted code in the last three blocks still looks delegated in that state.

  • Contracts are exempt

    Accounts holding regular code are exempt from the reserve balance check today. An EOA that adopted code would become exempt and could have its balance drained.

  • In-flight transactions

    Consensus can still admit transactions signed by the account's key for 3 blocks. Their gas has to stay payable.

k is RESERVE_BALANCE_DELAY_BLOCKS, 3 blocks.

Who can adopt code

When the current account holds a delegation indicator, SETCODEFROM halts unless one of two conditions holds.

  • It sent the transaction

    The adopting transaction puts the account in the sender window, so the reserve check keeps covering it for the rest of the 3-block window.

  • Its active reserve is 0

    Consensus admits no transaction from an account with a zero reserve, so nothing can be in flight. A relayer or bundler runs the migration at least 3 blocks after the account sets its reserve to 0.

  • Otherwise

    SETCODEFROM halts exceptionally, before SETCODEFROM_SOURCE_GAS is charged.

  • CREATE in the same frame

    Monad restricts CREATE and CREATE2 in a frame that started with a delegated account. Adopting code doesn't lift that for the rest of the frame. Frames that start afterwards can create contracts.

Accounts without a delegation indicator follow EIP-8298 as written.

What happens to in-flight transactions

A transaction signed by the old key can already be sequenced when the account adopts code. Execution includes it and fails it.

  1. 1. Still validated

    Signature, chain id, gas limit, intrinsic gas and the sender's balance are checked as today.

  2. 2. Nonce not compared

    The transaction's nonce is not validated against the sender's. The sender's nonce becomes one above the larger of the two.

  3. 3. Fees charged

    The transaction pays for its full gas limit. The receipt has status 0.

  4. 4. Nothing runs

    No value moves, no code runs, no contract is created and no log is emitted. The authorization list is still processed.

  5. 5. One failed frame

    The trace has one top-level frame that fails with a dedicated status.

Consensus must not sequence further transactions from a sender that holds regular code in the state it validates against.

Who this affects

Wallets and smart account teams

Two ways to migrate an EOA

Self-sent, which works as in EIP-8298, or through a relayer after setting the reserve to 0 and waiting 3 blocks.

Explorers and deployment tools

contractAddress on failed creations

For an in-flight creation transaction, interfaces must report the address of its top-level frame, derived from the sender's nonce in execution. The address derived from the transaction's own nonce can hold a live contract.

Contracts using MIP-4

dippedIntoReserve can be true for a contract

Until now only accounts with empty code or a delegation indicator could dip into reserve. A migrated account can too, in its adopting transaction and for the window after.

The Backwards Compatibility and Security Considerations sections say "Needs discussion" and the test cases are TBD. The spec says the design is currently incompatible with MCP and the Cadence consensus architecture, and that another MIP will revise it.

Continue the discussion on Monad Forum

Questions, feedback, or a better idea? Weigh in on the forum thread.

Open forum thread