{"eip":7405,"title":"Portable Smart Contract Accounts","description":"Migrating smart contract accounts at the Proxy (ERC-1967) layer.","authors":["Aaron Yee (@aaronyee-eth)"],"status":"Draft","type":"Standards Track","category":"ERC","created":"2023-07-26","requires":[191,1967],"discussionsTo":"https://ethereum-magicians.org/t/erc-7405-portable-smart-contract-accounts/15236","repo":"ERCs","label":"ERC-7405","officialUrl":"https://eips.ethereum.org/EIPS/eip-7405","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7405.md","url":"https://eips.huatuo.xyz/eip-7405/","tldr":{"en":"Lets a user move a proxy-based smart contract account from one wallet provider's implementation to another's using a one-time migration key and a time lock, much like exporting an EOA's private key.","ja":"プロキシ型のスマートコントラクトアカウントを、ワンタイムの移行キーとタイムロックを使って、あるウォレットプロバイダーの実装から別のプロバイダーの実装へ移せるようにする。EOA の秘密鍵をエクスポートするのによく似た方法。","ko":"프록시 기반 스마트 컨트랙트 계정을 일회용 마이그레이션 키와 타임락을 이용해 한 지갑 제공자의 구현에서 다른 제공자의 구현으로 옮길 수 있게 한다. EOA의 개인 키를 내보내는 것과 비슷하다.","zh":"让用户借助一次性迁移密钥和时间锁，把基于代理的智能合约账户从一个钱包提供商的实现迁移到另一个提供商的实现，这很像导出 EOA 的私钥。"},"tags":["account-abstraction","wallet","proxy","migration"],"explainers":{"en":{"lang":"en","tldr":"Lets a user move a proxy-based smart contract account from one wallet provider's implementation to another's using a one-time migration key and a time lock, much like exporting an EOA's private key.","tags":["account-abstraction","wallet","proxy","migration"],"related":[1967,4337,191,7201],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7405/","markdown":"## What problem does it solve?\n\nWith an externally-owned account (EOA) you can export your seed phrase from one wallet and import it into another. Smart contract accounts (SCAs), such as [ERC-4337](/eip-4337/) wallets, do not work that way: each wallet provider ships its own contract code, so your account address is effectively tied to the provider that deployed it. Switching providers means creating a new account and moving every asset by hand.\n\nERC-7405 proposes a migration path that works at the proxy layer. Most SCAs are [ERC-1967](/eip-1967/) proxies, so if the proxy can be safely re-pointed to Wallet B's implementation, the user keeps the same address and assets while changing provider.\n\n## How it works\n\n**Migration key.** For each migration, Wallet A generates a brand-new random private key or mnemonic (the \"random operator\") and shows it to the user. Its address identifies the migration.\n\n**Step 1: prepare (Wallet A).** The account calls `prepareAccountMigration(randomOperator, signature)`. This must be authenticated as the account itself (for example, coming through the ERC-4337 EntryPoint). It checks the operator's signature, records `{account, createTime, lockUntil}` in a shared `IERC7405Registry`, and locks the account.\n\n**Lock period.** While locked, the account should refuse asset transfers, external calls and changes to its authentication. The owner can call `cancelAccountMigration()` with normal account auth to abort, which protects against a stolen or malicious migration.\n\n**Step 2: handle (Wallet B).** The user imports the migration key into Wallet B, which calls `handleAccountMigration(newImplementation, initData, signature)`. This function is deliberately callable by anyone; it relies on the migration-key signature and requires that the lock has expired. It runs Wallet A's cleanup hook, swaps the ERC-1967 implementation slot, calls `initData` to set up Wallet B, deletes the registry entry and emits `AccountMigrated`.\n\n**Signatures** are [ERC-191](/eip-191/) signatures over `abi.encode(chainID, selector, data)`.\n\n**Storage layout.** To avoid one wallet's state clobbering another's, implementations must keep all state in a struct at a namespaced slot such as `keccak256(\"foo_wallet_v1.config\") - 1`, rather than declaring ordinary state variables.\n\n## Sample code\n\nThe account-side interface:\n\n```solidity\n// SPDX-License-Identifier: CC0-1.0\npragma solidity ^0.8.20;\n\ninterface IERC7405 {\n    event AccountMigrated(address oldImplementation, address newImplementation);\n\n    // Called via the account's own auth (e.g. EntryPoint) on the old wallet\n    function prepareAccountMigration(address randomOperator, bytes calldata signature) external;\n\n    // Called via the account's own auth to abort during the lock period\n    function cancelAccountMigration() external;\n\n    // Callable by anyone holding a valid migration-key signature, after lockUntil\n    function handleAccountMigration(\n        address newImplementation,\n        bytes calldata initData,\n        bytes calldata signature\n    ) external;\n}\n\n// Namespaced storage, as the spec recommends\nlibrary FooWalletStorage {\n    bytes32 constant SLOT = bytes32(uint256(keccak256(\"foo_wallet_v1.config\")) - 1);\n    struct Layout { address owner; uint256 nonce; }\n    function layout() internal pure returns (Layout storage l) {\n        bytes32 s = SLOT;\n        assembly { l.slot := s }\n    }\n}\n```\n\n## Things to know\n\n- Status is **Draft**, and the spec has no reference implementation yet.\n- The registry is meant to be a single shared contract; the spec does not give a deployment address.\n- The migration key is a bearer secret: anyone holding it can complete the migration once the lock expires. The lock period and owner notifications are the main defence.\n- The spec text names the step-2 function `handleWalletMigration` in one place but `handleAccountMigration` in the interface; the interface name is the one to implement.\n- The namespaced-storage idea is closely related to [ERC-7201](/eip-7201/).\n"},"ja":{"lang":"ja","tldr":"プロキシ型のスマートコントラクトアカウントを、ワンタイムの移行キーとタイムロックを使って、あるウォレットプロバイダーの実装から別のプロバイダーの実装へ移せるようにする。EOA の秘密鍵をエクスポートするのによく似た方法。","tags":["account-abstraction","wallet","proxy","migration"],"related":[1967,4337,191,7201],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7405/","markdown":"## 何を解決するのか\n\n外部所有アカウント（EOA）なら、あるウォレットからシードフレーズをエクスポートし、別のウォレットにインポートできます。[ERC-4337](/eip-4337/) ウォレットのようなスマートコントラクトアカウント（SCA）はそうはいきません。ウォレットプロバイダーごとに独自のコントラクトコードを提供しているため、アカウントのアドレスは事実上、それをデプロイしたプロバイダーに結び付いています。プロバイダーを乗り換えるには、新しいアカウントを作り、すべての資産を手作業で移す必要があります。\n\nERC-7405 は、プロキシ層で機能する移行経路を提案します。ほとんどの SCA は [ERC-1967](/eip-1967/) プロキシなので、プロキシを安全に Wallet B の実装へ向け直せれば、ユーザーは同じアドレスと資産のままプロバイダーを変更できます。\n\n## 仕組み\n\n**移行キー。** 移行のたびに、Wallet A はまったく新しいランダムな秘密鍵またはニーモニック（「ランダムオペレーター」）を生成し、ユーザーに提示します。そのアドレスが移行を識別します。\n\n**ステップ 1: 準備（Wallet A）。** アカウントが `prepareAccountMigration(randomOperator, signature)` を呼び出します。これはアカウント自身として認証されている必要があります（たとえば ERC-4337 EntryPoint 経由）。オペレーターの署名を検証し、共有の `IERC7405Registry` に `{account, createTime, lockUntil}` を記録して、アカウントをロックします。\n\n**ロック期間。** ロック中、アカウントは資産の転送、外部呼び出し、認証の変更を拒否する必要があります。所有者は通常のアカウント認証で `cancelAccountMigration()` を呼び出して中止でき、盗まれた、あるいは悪意のある移行から守られます。\n\n**ステップ 2: 処理（Wallet B）。** ユーザーは移行キーを Wallet B にインポートし、Wallet B が `handleAccountMigration(newImplementation, initData, signature)` を呼び出します。この関数は意図的に誰でも呼び出せるようになっており、移行キーの署名に依拠し、ロックが期限切れであることを要求します。Wallet A のクリーンアップフックを実行し、ERC-1967 の実装スロットを入れ替え、`initData` を呼んで Wallet B をセットアップし、レジストリのエントリを削除して `AccountMigrated` を emit します。\n\n**署名**は、`abi.encode(chainID, selector, data)` に対する [ERC-191](/eip-191/) 署名です。\n\n**ストレージレイアウト。** あるウォレットの状態が別のウォレットの状態を上書きしないよう、実装は通常の状態変数を宣言するのではなく、`keccak256(\"foo_wallet_v1.config\") - 1` のような名前空間付きスロットの struct にすべての状態を保持する必要があります。\n\n## サンプルコード\n\nアカウント側のインターフェース:\n\n```solidity\n// SPDX-License-Identifier: CC0-1.0\npragma solidity ^0.8.20;\n\ninterface IERC7405 {\n    event AccountMigrated(address oldImplementation, address newImplementation);\n\n    // Called via the account's own auth (e.g. EntryPoint) on the old wallet\n    function prepareAccountMigration(address randomOperator, bytes calldata signature) external;\n\n    // Called via the account's own auth to abort during the lock period\n    function cancelAccountMigration() external;\n\n    // Callable by anyone holding a valid migration-key signature, after lockUntil\n    function handleAccountMigration(\n        address newImplementation,\n        bytes calldata initData,\n        bytes calldata signature\n    ) external;\n}\n\n// Namespaced storage, as the spec recommends\nlibrary FooWalletStorage {\n    bytes32 constant SLOT = bytes32(uint256(keccak256(\"foo_wallet_v1.config\")) - 1);\n    struct Layout { address owner; uint256 nonce; }\n    function layout() internal pure returns (Layout storage l) {\n        bytes32 s = SLOT;\n        assembly { l.slot := s }\n    }\n}\n```\n\n## 知っておくべきこと\n\n- ステータスは **Draft** で、仕様にはまだリファレンス実装がありません。\n- レジストリは単一の共有コントラクトであることを意図していますが、仕様はデプロイアドレスを示していません。\n- 移行キーはベアラーシークレットです。これを持っている人は、ロックが期限切れになれば移行を完了できます。主な防御は、ロック期間と所有者への通知です。\n- 仕様の文章では、ステップ 2 の関数がある箇所では `handleWalletMigration`、インターフェースでは `handleAccountMigration` と書かれています。実装すべきなのはインターフェースの名前です。\n- 名前空間付きストレージの考え方は、[ERC-7201](/eip-7201/) と密接に関連しています。\n"},"ko":{"lang":"ko","tldr":"프록시 기반 스마트 컨트랙트 계정을 일회용 마이그레이션 키와 타임락을 이용해 한 지갑 제공자의 구현에서 다른 제공자의 구현으로 옮길 수 있게 한다. EOA의 개인 키를 내보내는 것과 비슷하다.","tags":["account-abstraction","wallet","proxy","migration"],"related":[1967,4337,191,7201],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7405/","markdown":"## 어떤 문제를 해결하나요?\n\n외부 소유 계정(EOA)은 한 지갑에서 시드 문구를 내보내 다른 지갑에 가져올 수 있습니다. [ERC-4337](/eip-4337/) 지갑 같은 스마트 컨트랙트 계정(SCA)은 그렇지 않습니다. 지갑 제공자마다 자체 컨트랙트 코드를 제공하므로 계정 주소가 사실상 이를 배포한 제공자에 묶여 있습니다. 제공자를 바꾸려면 새 계정을 만들고 모든 자산을 수작업으로 옮겨야 합니다.\n\nERC-7405는 프록시 계층에서 동작하는 마이그레이션 경로를 제안합니다. 대부분의 SCA는 [ERC-1967](/eip-1967/) 프록시이므로, 프록시를 안전하게 Wallet B의 구현으로 다시 가리키게 할 수 있다면 사용자는 같은 주소와 자산을 유지한 채 제공자를 바꿀 수 있습니다.\n\n## 어떻게 동작하나요?\n\n**마이그레이션 키.** 마이그레이션마다 Wallet A는 완전히 새로운 무작위 개인 키 또는 니모닉(\"랜덤 오퍼레이터\")을 생성해 사용자에게 보여 줍니다. 그 주소가 해당 마이그레이션을 식별합니다.\n\n**1단계: 준비(Wallet A).** 계정이 `prepareAccountMigration(randomOperator, signature)`를 호출합니다. 이는 계정 자신으로 인증되어야 합니다(예: ERC-4337 EntryPoint를 통해). 오퍼레이터의 서명을 확인하고, 공유 `IERC7405Registry`에 `{account, createTime, lockUntil}`을 기록한 뒤 계정을 잠급니다.\n\n**잠금 기간.** 잠겨 있는 동안 계정은 자산 전송, 외부 호출, 인증 변경을 거부해야 합니다. 소유자는 일반 계정 인증으로 `cancelAccountMigration()`을 호출해 중단할 수 있으며, 이는 도난되었거나 악의적인 마이그레이션을 막아 줍니다.\n\n**2단계: 처리(Wallet B).** 사용자가 마이그레이션 키를 Wallet B에 가져오면 Wallet B가 `handleAccountMigration(newImplementation, initData, signature)`를 호출합니다. 이 함수는 의도적으로 누구나 호출할 수 있게 되어 있으며, 마이그레이션 키의 서명에 의존하고 잠금이 만료되었을 것을 요구합니다. Wallet A의 정리 훅을 실행하고, ERC-1967 구현 슬롯을 교체하고, `initData`를 호출해 Wallet B를 설정하고, 레지스트리 항목을 삭제하고, `AccountMigrated`를 emit합니다.\n\n**서명**은 `abi.encode(chainID, selector, data)`에 대한 [ERC-191](/eip-191/) 서명입니다.\n\n**스토리지 레이아웃.** 한 지갑의 상태가 다른 지갑의 상태를 덮어쓰지 않도록, 구현은 일반 상태 변수를 선언하는 대신 `keccak256(\"foo_wallet_v1.config\") - 1` 같은 네임스페이스 슬롯의 struct에 모든 상태를 보관해야 합니다.\n\n## 샘플 코드\n\n계정 측 인터페이스:\n\n```solidity\n// SPDX-License-Identifier: CC0-1.0\npragma solidity ^0.8.20;\n\ninterface IERC7405 {\n    event AccountMigrated(address oldImplementation, address newImplementation);\n\n    // Called via the account's own auth (e.g. EntryPoint) on the old wallet\n    function prepareAccountMigration(address randomOperator, bytes calldata signature) external;\n\n    // Called via the account's own auth to abort during the lock period\n    function cancelAccountMigration() external;\n\n    // Callable by anyone holding a valid migration-key signature, after lockUntil\n    function handleAccountMigration(\n        address newImplementation,\n        bytes calldata initData,\n        bytes calldata signature\n    ) external;\n}\n\n// Namespaced storage, as the spec recommends\nlibrary FooWalletStorage {\n    bytes32 constant SLOT = bytes32(uint256(keccak256(\"foo_wallet_v1.config\")) - 1);\n    struct Layout { address owner; uint256 nonce; }\n    function layout() internal pure returns (Layout storage l) {\n        bytes32 s = SLOT;\n        assembly { l.slot := s }\n    }\n}\n```\n\n## 알아둘 점\n\n- 상태는 **Draft**이며, 명세에는 아직 참조 구현이 없습니다.\n- 레지스트리는 하나의 공유 컨트랙트로 의도되었지만 명세는 배포 주소를 제시하지 않습니다.\n- 마이그레이션 키는 소지자 비밀입니다. 이를 가진 사람은 잠금이 만료되면 마이그레이션을 완료할 수 있습니다. 잠금 기간과 소유자 알림이 주된 방어책입니다.\n- 명세 본문은 2단계 함수를 한 곳에서는 `handleWalletMigration`, 인터페이스에서는 `handleAccountMigration`이라고 부릅니다. 구현해야 할 것은 인터페이스의 이름입니다.\n- 네임스페이스 스토리지 개념은 [ERC-7201](/eip-7201/)과 밀접하게 관련되어 있습니다.\n"},"zh":{"lang":"zh","tldr":"让用户借助一次性迁移密钥和时间锁，把基于代理的智能合约账户从一个钱包提供商的实现迁移到另一个提供商的实现，这很像导出 EOA 的私钥。","tags":["account-abstraction","wallet","proxy","migration"],"related":[1967,4337,191,7201],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7405/","markdown":"## 它解决什么问题？\n\n对于外部拥有账户（EOA），你可以从一个钱包导出助记词，再导入另一个钱包。智能合约账户（SCA），例如 [ERC-4337](/eip-4337/) 钱包，则不是这样：每个钱包提供商都有自己的合约代码，因此你的账户地址实际上与部署它的提供商绑定。更换提供商意味着创建新账户并手动转移每一项资产。\n\nERC-7405 提出了一条在代理层工作的迁移路径。大多数 SCA 都是 [ERC-1967](/eip-1967/) 代理，因此如果能安全地把代理重新指向钱包 B 的实现，用户就可以在更换提供商的同时保留相同的地址和资产。\n\n## 它如何运作\n\n**迁移密钥。** 每次迁移，钱包 A 都会生成一个全新的随机私钥或助记词（\"随机操作员\"）并展示给用户。它的地址用来标识这次迁移。\n\n**步骤 1：准备（钱包 A）。** 账户调用 `prepareAccountMigration(randomOperator, signature)`。这必须以账户自身的身份通过认证（例如经由 ERC-4337 EntryPoint）。它会检查操作员的签名，在共享的 `IERC7405Registry` 中记录 `{account, createTime, lockUntil}`，并锁定账户。\n\n**锁定期。** 锁定期间，账户应拒绝资产转移、外部调用以及对其认证方式的更改。所有者可以用正常的账户认证调用 `cancelAccountMigration()` 来中止，这可以防范被盗或恶意的迁移。\n\n**步骤 2：处理（钱包 B）。** 用户把迁移密钥导入钱包 B，钱包 B 调用 `handleAccountMigration(newImplementation, initData, signature)`。该函数被刻意设计为任何人都可以调用；它依赖迁移密钥的签名，并要求锁定期已过。它会运行钱包 A 的清理钩子，替换 ERC-1967 的实现槽，调用 `initData` 来设置钱包 B，删除注册表条目并发出 `AccountMigrated`。\n\n**签名**是对 `abi.encode(chainID, selector, data)` 的 [ERC-191](/eip-191/) 签名。\n\n**存储布局。** 为避免一个钱包的状态覆盖另一个钱包的状态，实现必须把所有状态保存在位于命名空间槽位（例如 `keccak256(\"foo_wallet_v1.config\") - 1`）的 struct 中，而不是声明普通的状态变量。\n\n## 示例代码\n\n账户侧的接口：\n\n```solidity\n// SPDX-License-Identifier: CC0-1.0\npragma solidity ^0.8.20;\n\ninterface IERC7405 {\n    event AccountMigrated(address oldImplementation, address newImplementation);\n\n    // Called via the account's own auth (e.g. EntryPoint) on the old wallet\n    function prepareAccountMigration(address randomOperator, bytes calldata signature) external;\n\n    // Called via the account's own auth to abort during the lock period\n    function cancelAccountMigration() external;\n\n    // Callable by anyone holding a valid migration-key signature, after lockUntil\n    function handleAccountMigration(\n        address newImplementation,\n        bytes calldata initData,\n        bytes calldata signature\n    ) external;\n}\n\n// Namespaced storage, as the spec recommends\nlibrary FooWalletStorage {\n    bytes32 constant SLOT = bytes32(uint256(keccak256(\"foo_wallet_v1.config\")) - 1);\n    struct Layout { address owner; uint256 nonce; }\n    function layout() internal pure returns (Layout storage l) {\n        bytes32 s = SLOT;\n        assembly { l.slot := s }\n    }\n}\n```\n\n## 需要注意\n\n- 状态为 **Draft**，规范目前还没有参考实现。\n- 注册表意在作为一个共享的单一合约；规范没有给出部署地址。\n- 迁移密钥是持有者凭证：锁定期一过，任何持有它的人都能完成迁移。锁定期和对所有者的通知是主要的防御手段。\n- 规范文本在一处把步骤 2 的函数叫作 `handleWalletMigration`，而在接口中叫作 `handleAccountMigration`；应实现的是接口中的名称。\n- 命名空间存储的思路与 [ERC-7201](/eip-7201/) 密切相关。\n"}}}
