EIP-7377 Migration transaction

No call decision · Account abstraction · EIP status Stagnant · created 2023-07-21

Introduces a new transaction type (0x04) that lets an EOA deploy code to its own address with a single signature, converting it into a smart contract wallet.

Why it is needed

Moving assets currently held in an EOA into a smart contract wallet today requires sending each asset to the new address one at a time. The more token types involved, the more individual transactions a user has to sign and confirm, which is costly and time consuming, and carries the risk of mistakes during signing. As a result, many users remain on EOAs even though they are aware of the benefits of smart contract wallets. Various efforts have advanced account abstraction, but efficiently converting existing EOA users who already hold assets has been neglected. This EIP provides a protocol level way to migrate an EOA into a smart contract, letting existing users change only the nature of their address while keeping their assets in place.

What changes

Today

After EIP-7377

Who is affected

In depth

Transaction format and signing

The EIP-2718 TransactionType is 0x04, and the TransactionPayload is rlp([chainId, nonce, maxFeePerGas, maxPriorityFeePerGas, gasLimit, codeAddr, storage, data, value, accessList, yParity, r, s]). The signing hash is computed as keccak256(0x04 || rlp([...])) over all fields except yParity, r, and s. codeAddr is a pointer to an address where the code to be deployed already exists, and storage is a list of (key, value) tuples to be applied as storage values immediately after deployment.

Validity conditions

All of EIP-1559's validity conditions apply as is, with the additional requirement that the code size at codeAddr must be greater than 0 and less than the EIP-170 limit of 24576 bytes. Intrinsic gas is calculated using a modified EIP-1559 formula: 21000 + 16 × non-zero calldata bytes + 4 × zero calldata bytes + 1900 × access list storage key count + 2400 × access list address count + 20000 × length of storage.

Processing: deployment and execution

Processing happens in two stages. First, in the contract deployment stage, the sending account's code is set to state[tx.codeAddr].code, and each tuple in tx.storage is written into the sending account's storage trie. Next, in the transaction execution stage, an EVM call is executed on the sending account itself under the same rules as EIP-1559, except that the transaction's origin is set to keccak256(sender)[0..20].

Why there is no to field

This transaction is designed as a one time mechanism for converting an EOA into a smart contract. It is built to immediately call the just deployed contract, which is the sender's own address, right after deployment, allowing the user to perform additional initialization. This is why a separate to field is not needed.

Why a pointer is used instead of embedding the code directly

It would be possible to carry the code directly as a bytes type field, but since many users would be deploying the exact same wallet code, this would waste calldata by duplicating identical code repeatedly. Instead, this common case is optimized by using a pointer (codeAddr) to code that is already deployed.

Why storage is cheaper

Because the storage being migrated is guaranteed to always start empty, there is no need to read it before writing. So only EIP-2200's SSTORE_SET_GAS value of 20000 needs to be paid. This is slightly cheaper than the usual 22100, which adds EIP-2929's COLD_SLOAD_COST of 2100, since no load occurs.

Risks around origin manipulation and ecrecover

Many applications use a caller == origin check to verify that a caller is an EOA. This EIP sets origin to keccak256(sender)[0..20] so that this check keeps working. Meanwhile, once an EOA can have code, standards like ERC-2612 Permit that rely on the relationship between an EOA address and its private key via ecrecover could become vulnerable. An attack is noted where a protocol could deploy its own contract using this EIP and later drain funds accumulated inside it using an ERC-2612 signature, and having wallets block interaction with protocols deployed this way is proposed as a defense. A mitigation is also mentioned that adds an EXTCODEHASH check to ecrecover, reverting if the account has code.

One time design and current status

It would technically be possible to let an EOA change its code with this transaction at any time, but because EIP-3607 already invalidates migration transactions from accounts that already have deployed code, only a one time conversion is practically possible. This also has the effect of making it simpler to reason about contracts and their upgradeability. This EIP is currently in Stagnant status, so it has not yet been adopted or reached an implementation stage.

Original EIP · ← EIPs