EIPs Explained

EIP-7377 · Stagnant · Core · 2023-07-21

EIP-7377: Migration Transaction

A proposed one-time transaction type that turns an existing EOA into a smart contract wallet in place, keeping its address and assets.

What problem does it solve?

Smart contract wallets offer recovery, batching, spending limits and more, but most users still hold assets in plain EOAs. Moving to a new contract address means transferring every token, NFT and position one by one, which is expensive and tedious. Many users never do it.

EIP-7377 proposed a protocol-level shortcut: let an EOA send one special transaction that installs contract code at its own address, so the account becomes a smart contract without moving anything.

How it works

A new EIP-2718 transaction type 0x04:

0x04 || rlp([chainId, nonce, maxFeePerGas, maxPriorityFeePerGas, gasLimit,
             codeAddr, storage, data, value, accessList, yParity, r, s])
  • There is no to field. Instead, codeAddr points to an already-deployed contract whose code is copied onto the sender's account. Pointing at existing code avoids putting the same wallet bytecode in calldata over and over.
  • storage is a list of (slot, value) pairs written into the sender's storage, for example to set the wallet owner.
  • After that, the transaction makes a normal EIP-1559-style call into the sender's (now contract) account with data and value, so it can run any initialisation.
  • The code at codeAddr must be non-empty and below the 24,576-byte limit.
  • Intrinsic gas is the usual 1559 formula plus 20,000 gas per storage tuple. No extra charge for deployment, since clients store identical code once.
  • During execution tx.origin is set to keccak256(sender)[0..20] rather than the sender, so existing msg.sender == tx.origin "is this an EOA?" checks keep behaving.

Because of EIP-3607 (accounts with code cannot send transactions), the migration can only happen once.

Sample code

Pseudocode of what a client does when processing the transaction:

def apply_migration_tx(state, tx, sender):
    code = state[tx.codeAddr].code
    assert 0 < len(code) < 24576
    state[sender].code = code                 # install wallet code at the EOA
    for slot, value in tx.storage:
        state[sender].storage[slot] = value   # e.g. owner, guardians
    origin = keccak256(sender)[:20]           # rewritten tx.origin
    return evm_call(caller=sender, to=sender, origin=origin,
                    data=tx.data, value=tx.value)

Things to know

  • Status is Stagnant. It was not scheduled for any network upgrade.
  • The underlying goal, giving EOAs smart-account features, was addressed in Pectra by EIP-7702, which lets an EOA delegate to contract code instead of permanently replacing its code.
  • The private key still exists after migration. Signature-based schemes such as ERC-2612 permit could still be signed with it, so revealing or losing the key would remain dangerous. Migration also happens per chain, so the same address on other chains stays a plain EOA.
  • Wallets would need to treat this transaction type with extreme care, since a blind-signed migration could hand the account to an attacker's code.

#account-abstraction #transactions #eoa #core

Details

Authors
lightclient (@lightclient), Sam Wilson (@samwilsn), Ansgar Dietrichs (@adietrichs)
Status
Stagnant
Type
Standards Track / Core
Created
2023-07-21
Requires

Machine-readable: Markdown · JSON