Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

This article examines EIP-7377, a proposed mechanism for migrating an externally owned account (EOA) to a smart contract account without separately transferring each asset to a new wallet.

This article translates, summarizes, and expands on the following specification.

More EIP explainers:

Overview

EIP-2718 defines a typed transaction envelope for Ethereum, allowing new transaction formats to be introduced.

EIP-7377 proposes a migration transaction, identified in the historical proposal as type 0x04, that installs existing contract code at the sender's address and initializes its storage.

This is a proposal described in the original April 2024 article, not a description of an activated Ethereum transaction type. Ethereum subsequently assigned type 0x04 to EIP-7702 set-code transactions, which have different semantics.

Transaction format

The proposed transaction has the following format.

text
0x04 || rlp([chainId, nonce, maxFeePerGas, maxPriorityFeePerGas, gasLimit, codeAddr, storage, data, value, accessList, yParity, r, s])
  • chainId — the ID of the chain on which the transaction executes.
  • nonce — the sender's transaction count.
  • maxFeePerGas — the maximum fee per gas.
  • maxPriorityFeePerGas — the maximum priority fee per gas.
  • gasLimit — the maximum gas available to the transaction.
  • codeAddr — the address containing the code to install.
  • storage — a list of storage key-value pairs.
  • data — transaction data.
  • value — the amount of Ether associated with the call.
  • accessList — addresses and storage keys declared for access-list pricing.
  • yParity, r, s — ECDSA signature parameters.

Main functionality

The proposed transaction installs code and initializes storage:

  1. Install code
    • Retrieve the code at codeAddr and assign it to the sender account's code field.
    • This changes the account from an EOA into a contract account under the proposal.
  2. Apply storage
    • Update the sender's storage trie using the key-value pairs in storage.
    • This initializes the account's internal state.

Significance and use cases

The proposal aims to simplify the transition to smart contract wallets and support extensible account designs. It does not provide unrestricted repeated replacement of deployed account code; the migration itself is intended to be a one-time operation.

Motivation

Account abstraction is an important direction for improving Ethereum's user experience and supporting smart contract wallets.

What is account abstraction?

Account abstraction seeks to make account behavior more flexible and reduce the need for applications and users to manage differences between EOAs and contract accounts directly. It can simplify the experience of interacting with Ethereum.

For more information about account abstraction, see:

[ERC4337] Account Abstraction Without Protocol Changes

Existing problems

Many Ethereum users have historically used EOAs controlled directly by private keys. Managing those keys presents security challenges.

Migrating to a new smart contract wallet may require paying fees and separately authorizing transactions to transfer assets. This is particularly burdensome for users holding many different assets.

Proposed solution

EIP-7377 aims to introduce protocol-level support for migrating EOAs into smart contract accounts. By keeping the existing address and installing code there, the proposal seeks to avoid transferring individual assets to a new address.

This could reduce migration costs and simplify the process of adopting smart contract wallets.

Expected effects

A lower migration barrier could encourage broader wallet adoption and integration. Improved account functionality may support better security and usability, depending on the wallet implementation and its authorization model.

Specification

The migration transaction would be introduced at a designated fork block X. A protocol fork activates new consensus rules.

Fork block X

Block X is a placeholder for the activation point at which the proposed transaction rules would become effective. It is not a scheduled activation date established by this article.

Migration transaction

The proposal builds on EIP-2718 by defining a new typed transaction.

Transaction fields

Field Type
chainId uint256
nonce uint64
maxFeePerGas uint256
maxPriorityFeePerGas uint256
gasLimit uint64
codeAddr address
storage List[Tuple[uint256, uint256]]
data bytes
value uint256
accessList List[Tuple[address, List[uint256]]]
yParity uint8
r uint256
s uint256

Transaction payload

The historical proposal uses transaction type 0x04 followed by an RLP-encoded payload whose fields appear in the specified order.

RLP (Recursive Length Prefix) is an Ethereum encoding format for byte strings and nested lists. Ethereum uses RLP in several transaction and execution-layer data structures.

How RLP works

RLP defines encoding rules for individual byte strings and lists.

Encoding a byte string

A single byte in the range 0x00 through 0x7f is encoded as itself.

For a short byte string of up to 55 bytes that does not qualify for that rule, add 0x80 to its length to produce a prefix, then append the string. Longer byte strings use a separate length-of-length encoding.

Encoding a list

Encode each item recursively. For a short list whose encoded payload is no longer than 55 bytes, add 0xc0 to its payload length and append the encoded items. Longer lists use a separate length-of-length encoding.

Example

To encode the string "dog":

  • Its bytes are 0x646f67.
  • Its length is 3, so the prefix is 0x83.
  • The RLP encoding is 0x83646f67.

Advantages of RLP

  • Simplicity — a small set of encoding rules.
  • Efficiency — compact representation for many data structures.
  • Generality — support for byte strings and recursively nested lists.

RLP is a core encoding component in Ethereum.

Signing hash

The transaction signing hash is calculated with keccak256 according to the proposed typed transaction format. The signature binds the sender's authorization to the transaction's contents.

Transaction validation

The transaction must satisfy:

  • The applicable EIP-1559 validity conditions unless otherwise specified.
  • The code at codeAddr must not exceed the EIP-170 maximum of 24,576 bytes.
  • The code at codeAddr must not be empty.

For more information about EIP-170, see:

[EIP170] Contract Code Size Limit

Gas calculation

The proposal modifies the intrinsic gas calculation used for EIP-1559 transactions:

  • Base cost: 21000 gas.
  • Each nonzero calldata byte: 16 gas.
  • Each zero calldata byte: 4 gas.
  • Each access-list storage key: 1900 gas.
  • Each access-list address: 2400 gas.
  • Each storage-list entry: 20000 gas.

These are the historical proposal's parameters, not a complete current gas estimate.

Transaction processing

  1. Install contract code
    • Set the sender's code to state[tx.codeAddr].code.
    • Update the sender's storage trie using the tuples in the transaction's storage list.
  2. Execute the transaction
    • Perform an EVM call to the sender account under the applicable EIP-1559 rules.
    • Set the transaction origin to keccak256(sender)[0..20] as described in the proposal.

This mechanism aims to reduce the work and costs involved in migrating an EOA into a smart contract wallet.

Additional explanation

No to address field

The transaction targets the sender's own account rather than a separately specified destination. Since that account becomes a contract account, a to field is unnecessary.

The migration is intended to occur once, and the transaction can invoke the installed code immediately afterward.

Code pointer for deployment

The codeAddr field refers to existing code. If many users want to install the same wallet code, referring to that code can avoid repeatedly including identical bytecode in transaction data.

Cheaper storage

The account's newly initialized storage is assumed to be empty. The proposal therefore charges 20,000 gas per storage entry, corresponding to EIP-2200's SSTORE_SET_GAS, instead of 22,100 gas including the EIP-2929 cold-access charge of 2,100 gas.

For more information about EIP-2929, see:

[EIP2929] Gas Cost Increases for State Access Opcodes

Intrinsic gas excludes contract deployment

The proposal does not charge the ordinary code-deployment cost in its intrinsic gas calculation. Clients can store a single copy of identical code and refer to it by its code hash rather than duplicating that code for each account.

Manipulating transaction origin

Some applications historically used caller == origin to identify direct EOA calls. The proposal changes the origin for the migration transaction so that execution by the newly installed contract does not inadvertently satisfy such a check.

Such checks should not generally be treated as robust account-type or authorization guarantees.

One-time migration

Repeated changes of an EOA's code could be designed at the protocol level, but the proposal relies on EIP-3607 to reject subsequent migration transactions from accounts that already contain code. This simplifies the account's upgradeability model.

For more information about EIP-3607, see:

[EIP3607] Rejecting Transactions from Senders with Deployed Code

The proposal thereby seeks an efficient one-time migration rather than repeated protocol-level code replacement.

Security

Blind signing

Complex account functionality can make it harder for users to understand what they are authorizing. A user could inadvertently sign a migration transaction installing code controlled by a malicious party.

Wallets should clearly identify the consequences of the migration, verify the code and initialization data, and require appropriate confirmation before signing.

Use of ecrecover

The ecrecover precompile recovers an address from a signed message hash and ECDSA signature. Standards such as ERC-2612 rely on the cryptographic relationship between an EOA address and its private key.

For more information about ERC-2612, see:

[ERC2612] ERC-20 Permit Approvals

Many tokens implement permit, allowing approval to be authorized through a signature. A migrated account may still correspond to its original private key, introducing additional security considerations when external applications continue to recognize signatures from that key.

The original proposal discusses the possibility of a malicious protocol using a migrated address and later exercising signature-based approval rights over assets held at that address. Wallets and applications must account for this risk rather than assume that deployed code makes the original private key irrelevant.

Cross-chain implications

Migrating an EOA simultaneously on every chain is impractical. The original private key may still control the same address on other EVM-compatible chains. Migration does not make it safe to reveal or discard the private key without considering the other chains on which it is used.

Proposed mitigation

The historical proposal discusses adding an EXTCODEHASH check to ecrecover so that recovery involving an account containing code would revert. This would affect standards such as ERC-2612 when used with migrated EOAs.

This is a proposed mitigation, not a statement about the current behavior of the ecrecover precompile.

Citation

lightclient (@lightclient), Sam Wilson (@samwilsn), Ansgar Dietrichs (@adietrichs), "EIP-7377: Migration Transaction [DRAFT]," Ethereum Improvement Proposals, no. 7377, July 2023. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-7377.

Conclusion

EIP-7377 proposes a one-time transaction for installing code and initializing storage at an EOA's existing address, reducing the need for individual asset transfers when migrating to a smart contract wallet.

If you have questions, feel free to contact me on Twitter.

Twitter @cardene777

I also publish material on the following platforms.

https://chaldene.net/