{"eip":7895,"title":"API for Hierarchical Accounts","description":"Adds JSON-RPC method for requesting that a universal wallet create or track another account that it owns","authors":["Wilson Cusack (@wilsoncusack)","Jake Feldman (@jakefeldman)","Montana Wong (@montycheese)","Felix Zhang (@fan-zhang-sv)","Jake Moxey (@jxom)"],"status":"Draft","type":"Standards Track","category":"ERC","created":"2025-02-18","discussionsTo":"https://ethereum-magicians.org/t/wallet-addsubaccount/23013","repo":"ERCs","label":"ERC-7895","officialUrl":"https://eips.ethereum.org/EIPS/eip-7895","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7895.md","url":"https://eips.huatuo.xyz/eip-7895/","tldr":{"en":"A wallet RPC, wallet_addSubAccount, that lets an app ask a user's universal wallet to create or track an app-specific smart account the wallet owns, so app accounts stop being scattered and orphaned.","ja":"ウォレット RPC の wallet_addSubAccount。アプリがユーザーのユニバーサルウォレットに、ウォレットが所有するアプリ専用のスマートアカウントを作成または追跡するよう依頼でき、アプリのアカウントが散らばったり孤立したりしないようにする。","ko":"지갑 RPC인 wallet_addSubAccount. 앱이 사용자의 유니버설 지갑에 지갑이 소유하는 앱 전용 스마트 계정을 만들거나 추적해 달라고 요청할 수 있게 해, 앱 계정이 흩어지거나 방치되지 않도록 한다.","zh":"一个钱包 RPC：wallet_addSubAccount，让应用请求用户的通用钱包创建或跟踪一个由钱包拥有的、应用专属的智能账户，避免应用账户四处分散、沦为孤儿。"},"tags":["wallet","json-rpc","smart-account","sub-account","erc"],"explainers":{"en":{"lang":"en","tldr":"A wallet RPC, wallet_addSubAccount, that lets an app ask a user's universal wallet to create or track an app-specific smart account the wallet owns, so app accounts stop being scattered and orphaned.","tags":["wallet","json-rpc","smart-account","sub-account","erc"],"related":[5792,7846,4337],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7895/","markdown":"## What problem does it solve?\n\nMany apps give users an *embedded* account: a smart account that only exists inside that app. Users end up with dozens of addresses they cannot see or control from their main wallet. Smart accounts can already own other smart accounts, so a universal wallet could in principle control those app accounts, but there was no standard way for an app to tell the wallet \"this account belongs to you\" or \"please make one for me.\"\n\nERC-7895 defines that request, creating a **hierarchy**: the universal wallet is an owner (signer) of the app's **sub-account**.\n\n## How it works\n\nThe app calls `wallet_addSubAccount` with one of three account descriptions:\n\n| `type` | Meaning |\n| --- | --- |\n| `create` | Wallet creates a new sub-account. The app may pass signing `keys` (types `address`, `p256`, `webcrypto-p256`, `webauthn-p256`); if none are given, the wallet creates and manages the key. The universal account SHOULD be made an owner. |\n| `deployed` | Import an account that already exists onchain at `address`. |\n| `undeployed` | A counterfactual account: the app supplies `address`, `factory` and `factoryData`. The wallet SHOULD check (by decoding or simulating) that the universal account is an owner and may deploy it when first needed. |\n\nThe response returns the sub-account `address`, plus `factory` and `factoryData` when available.\n\nIt also plugs into existing wallet APIs: `wallet_getCapabilities` ([ERC-5792](/eip-5792/)) can advertise `addSubAccount` support and accepted key types per chain, and `wallet_connect` ([ERC-7846](/eip-7846/)) gains `addSubAccount` and `subAccounts` capabilities so an app can add or list sub-accounts during connection.\n\n## Sample code\n\nRequesting a new sub-account with an app-held passkey via an EIP-1193 provider:\n\n```ts\nconst caps = await provider.request({\n  method: \"wallet_getCapabilities\",\n  params: [userAddress],\n});\n// e.g. caps[\"0x2105\"].addSubAccount -\u003e { supported: true, keyTypes: [...] }\n\nconst sub = await provider.request({\n  method: \"wallet_addSubAccount\",\n  params: [{\n    version: \"1\",\n    account: {\n      type: \"create\",\n      keys: [{ type: \"webauthn-p256\", publicKey: \"0x...\" }],\n    },\n  }],\n});\nconsole.log(sub.address, sub.factory, sub.factoryData);\n```\n\n## Things to know\n\n- Status: **Draft**. Method names, fields and versioning may still change, and the dependency on ERC-7846 is itself still in Draft.\n- \"Account\" here means a smart account; ownership is enforced by the account contract, not by the RPC. A wallet should verify the hierarchy rather than trust the app's claim.\n- The spec frames the universal wallet's access as a safety net for funds in app accounts, but it also widens what the main wallet can sign for, so wallets should show clear prompts.\n- Account and capability data shared over this API should be protected against leaks and man-in-the-middle tampering.\n"},"ja":{"lang":"ja","tldr":"ウォレット RPC の wallet_addSubAccount。アプリがユーザーのユニバーサルウォレットに、ウォレットが所有するアプリ専用のスマートアカウントを作成または追跡するよう依頼でき、アプリのアカウントが散らばったり孤立したりしないようにする。","tags":["wallet","json-rpc","smart-account","sub-account","erc"],"related":[5792,7846,4337],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7895/","markdown":"## 何を解決するのか\n\n多くのアプリは、ユーザーに*埋め込み*アカウントを与えます。そのアプリの中にしか存在しないスマートアカウントです。ユーザーは、メインのウォレットから見ることも制御することもできない、数十ものアドレスを持つことになります。スマートアカウントはすでに他のスマートアカウントを所有できるので、ユニバーサルウォレットは原理的にはそれらのアプリのアカウントを制御できますが、アプリがウォレットに「このアカウントはあなたのものです」あるいは「私のために 1 つ作ってください」と伝える標準的な方法がありませんでした。\n\nERC-7895 はそのリクエストを定義し、**階層**を作ります。ユニバーサルウォレットは、アプリの**サブアカウント**の所有者（署名者）になります。\n\n## 仕組み\n\nアプリは、3 つのアカウント記述のいずれかを付けて `wallet_addSubAccount` を呼び出します。\n\n| `type` | 意味 |\n| --- | --- |\n| `create` | ウォレットが新しいサブアカウントを作成します。アプリは署名用の `keys`（タイプは `address`、`p256`、`webcrypto-p256`、`webauthn-p256`）を渡せます。何も渡されなければ、ウォレットが鍵を作成して管理します。ユニバーサルアカウントを所有者にするべき（SHOULD）です。 |\n| `deployed` | `address` のオンチェーンにすでに存在するアカウントをインポートします。 |\n| `undeployed` | カウンターファクチュアルなアカウント。アプリが `address`、`factory`、`factoryData` を渡します。ウォレットは、ユニバーサルアカウントが所有者であることを（デコードまたはシミュレーションで）確認するべき（SHOULD）で、最初に必要になったときにデプロイしてもかまいません。 |\n\nレスポンスは、サブアカウントの `address` を返し、利用可能な場合は `factory` と `factoryData` も返します。\n\nまた、既存のウォレット API にも組み込まれます。`wallet_getCapabilities`（[ERC-5792](/eip-5792/)）は、チェーンごとに `addSubAccount` のサポートと受け付ける鍵のタイプを通知でき、`wallet_connect`（[ERC-7846](/eip-7846/)）には `addSubAccount` と `subAccounts` の capability が加わり、アプリが接続中にサブアカウントを追加または一覧できるようになります。\n\n## サンプルコード\n\nEIP-1193 プロバイダー経由で、アプリが保持するパスキーを使った新しいサブアカウントをリクエストする例:\n\n```ts\nconst caps = await provider.request({\n  method: \"wallet_getCapabilities\",\n  params: [userAddress],\n});\n// e.g. caps[\"0x2105\"].addSubAccount -\u003e { supported: true, keyTypes: [...] }\n\nconst sub = await provider.request({\n  method: \"wallet_addSubAccount\",\n  params: [{\n    version: \"1\",\n    account: {\n      type: \"create\",\n      keys: [{ type: \"webauthn-p256\", publicKey: \"0x...\" }],\n    },\n  }],\n});\nconsole.log(sub.address, sub.factory, sub.factoryData);\n```\n\n## 知っておくべきこと\n\n- ステータス: **Draft**。メソッド名、フィールド、バージョニングはまだ変わる可能性があり、ERC-7846 への依存自体もまだ Draft です。\n- ここでの「アカウント」はスマートアカウントを指します。所有権は RPC ではなくアカウントコントラクトによって強制されます。ウォレットは、アプリの主張を信じるのではなく、階層を検証するべきです。\n- 仕様は、ユニバーサルウォレットのアクセスを、アプリのアカウント内の資金に対するセーフティネットとして位置づけていますが、同時にメインウォレットが署名できる範囲を広げるため、ウォレットは明確なプロンプトを表示するべきです。\n- この API を通じて共有されるアカウントと capability のデータは、漏えいや中間者による改ざんから保護する必要があります。\n"},"ko":{"lang":"ko","tldr":"지갑 RPC인 wallet_addSubAccount. 앱이 사용자의 유니버설 지갑에 지갑이 소유하는 앱 전용 스마트 계정을 만들거나 추적해 달라고 요청할 수 있게 해, 앱 계정이 흩어지거나 방치되지 않도록 한다.","tags":["wallet","json-rpc","smart-account","sub-account","erc"],"related":[5792,7846,4337],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7895/","markdown":"## 어떤 문제를 해결하나요?\n\n많은 앱이 사용자에게 *임베디드* 계정을 줍니다. 그 앱 안에서만 존재하는 스마트 계정입니다. 사용자는 메인 지갑에서 보거나 제어할 수 없는 수십 개의 주소를 갖게 됩니다. 스마트 계정은 이미 다른 스마트 계정을 소유할 수 있으므로 유니버설 지갑은 원칙적으로 그런 앱 계정을 제어할 수 있지만, 앱이 지갑에 \"이 계정은 당신 것입니다\" 또는 \"나를 위해 하나 만들어 주세요\"라고 알리는 표준 방법이 없었습니다.\n\nERC-7895는 그 요청을 정의하고 **계층 구조**를 만듭니다. 유니버설 지갑은 앱의 **서브 계정**의 소유자(서명자)가 됩니다.\n\n## 어떻게 동작하나요?\n\n앱은 세 가지 계정 설명 중 하나를 담아 `wallet_addSubAccount`를 호출합니다.\n\n| `type` | 의미 |\n| --- | --- |\n| `create` | 지갑이 새 서브 계정을 만듭니다. 앱은 서명용 `keys`(타입은 `address`, `p256`, `webcrypto-p256`, `webauthn-p256`)를 넘길 수 있습니다. 아무것도 주어지지 않으면 지갑이 키를 만들고 관리합니다. 유니버설 계정을 소유자로 해야 합니다(SHOULD). |\n| `deployed` | `address`의 온체인에 이미 존재하는 계정을 가져옵니다. |\n| `undeployed` | 반사실적(counterfactual) 계정. 앱이 `address`, `factory`, `factoryData`를 제공합니다. 지갑은 유니버설 계정이 소유자인지 (디코딩이나 시뮬레이션으로) 확인해야 하며(SHOULD), 처음 필요할 때 배포할 수 있습니다. |\n\n응답은 서브 계정의 `address`를 반환하고, 가능하면 `factory`와 `factoryData`도 반환합니다.\n\n기존 지갑 API에도 연결됩니다. `wallet_getCapabilities`([ERC-5792](/eip-5792/))는 체인별로 `addSubAccount` 지원과 허용하는 키 타입을 알릴 수 있고, `wallet_connect`([ERC-7846](/eip-7846/))에는 `addSubAccount`와 `subAccounts` capability가 추가되어 앱이 연결 중에 서브 계정을 추가하거나 나열할 수 있습니다.\n\n## 샘플 코드\n\nEIP-1193 provider를 통해 앱이 가진 패스키로 새 서브 계정을 요청하는 예:\n\n```ts\nconst caps = await provider.request({\n  method: \"wallet_getCapabilities\",\n  params: [userAddress],\n});\n// e.g. caps[\"0x2105\"].addSubAccount -\u003e { supported: true, keyTypes: [...] }\n\nconst sub = await provider.request({\n  method: \"wallet_addSubAccount\",\n  params: [{\n    version: \"1\",\n    account: {\n      type: \"create\",\n      keys: [{ type: \"webauthn-p256\", publicKey: \"0x...\" }],\n    },\n  }],\n});\nconsole.log(sub.address, sub.factory, sub.factoryData);\n```\n\n## 알아둘 점\n\n- 상태: **Draft**. 메서드 이름, 필드, 버전 관리가 아직 바뀔 수 있고, ERC-7846에 대한 의존성 자체도 아직 Draft입니다.\n- 여기서 \"계정\"은 스마트 계정을 뜻합니다. 소유권은 RPC가 아니라 계정 컨트랙트가 강제합니다. 지갑은 앱의 주장을 믿기보다 계층 구조를 검증해야 합니다.\n- 스펙은 유니버설 지갑의 접근을 앱 계정 속 자금에 대한 안전망으로 설명하지만, 메인 지갑이 서명할 수 있는 범위도 넓어지므로 지갑은 명확한 안내 프롬프트를 보여 줘야 합니다.\n- 이 API를 통해 공유되는 계정과 capability 데이터는 유출과 중간자 변조로부터 보호해야 합니다.\n"},"zh":{"lang":"zh","tldr":"一个钱包 RPC：wallet_addSubAccount，让应用请求用户的通用钱包创建或跟踪一个由钱包拥有的、应用专属的智能账户，避免应用账户四处分散、沦为孤儿。","tags":["wallet","json-rpc","smart-account","sub-account","erc"],"related":[5792,7846,4337],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7895/","markdown":"## 它解决什么问题？\n\n许多应用会给用户一个*嵌入式*账户：只存在于该应用内部的智能账户。用户最终拥有几十个地址，既看不到，也无法从自己的主钱包控制。智能账户本来就可以拥有其他智能账户，所以通用钱包原则上可以控制这些应用账户，但应用没有标准的方式告诉钱包\"这个账户属于你\"或\"请为我创建一个\"。\n\nERC-7895 定义了这一请求，并建立一种**层级关系**：通用钱包是应用**子账户**的所有者（签名者）。\n\n## 它如何运作\n\n应用调用 `wallet_addSubAccount`，并传入三种账户描述之一：\n\n| `type` | 含义 |\n| --- | --- |\n| `create` | 钱包创建一个新的子账户。应用可以传入签名 `keys`（类型为 `address`、`p256`、`webcrypto-p256`、`webauthn-p256`）；如果没有传入，则由钱包创建并管理密钥。应当（SHOULD）让通用账户成为所有者。 |\n| `deployed` | 导入已在链上 `address` 处存在的账户。 |\n| `undeployed` | 反事实（counterfactual）账户：应用提供 `address`、`factory` 和 `factoryData`。钱包应当（SHOULD）检查（通过解码或模拟）通用账户是所有者，并可以在首次需要时部署它。 |\n\n响应返回子账户的 `address`，在可用时还包括 `factory` 和 `factoryData`。\n\n它还接入现有的钱包 API：`wallet_getCapabilities`（[ERC-5792](/eip-5792/)）可以按链声明对 `addSubAccount` 的支持以及接受的密钥类型，`wallet_connect`（[ERC-7846](/eip-7846/)）新增 `addSubAccount` 和 `subAccounts` 能力，使应用可以在连接过程中添加或列出子账户。\n\n## 示例代码\n\n通过 EIP-1193 provider，使用应用持有的 passkey 请求一个新的子账户：\n\n```ts\nconst caps = await provider.request({\n  method: \"wallet_getCapabilities\",\n  params: [userAddress],\n});\n// e.g. caps[\"0x2105\"].addSubAccount -\u003e { supported: true, keyTypes: [...] }\n\nconst sub = await provider.request({\n  method: \"wallet_addSubAccount\",\n  params: [{\n    version: \"1\",\n    account: {\n      type: \"create\",\n      keys: [{ type: \"webauthn-p256\", publicKey: \"0x...\" }],\n    },\n  }],\n});\nconsole.log(sub.address, sub.factory, sub.factoryData);\n```\n\n## 需要注意\n\n- 状态：**Draft**。方法名、字段和版本控制仍可能改变，对 ERC-7846 的依赖本身也仍是 Draft。\n- 这里的\"账户\"指智能账户；所有权由账户合约强制执行，而不是由 RPC 强制。钱包应当验证层级关系，而不是相信应用的说法。\n- 规范把通用钱包的访问权限定位为应用账户中资金的安全网，但这也扩大了主钱包可以签名的范围，因此钱包应当给出清晰的提示。\n- 通过该 API 共享的账户和能力数据应当防止泄露和中间人篡改。\n"}}}
