From 6f309c08c5792d7d566524abe1ac8d802f70e475 Mon Sep 17 00:00:00 2001 From: jakeFeldman Date: Thu, 27 Feb 2025 10:36:52 -0700 Subject: [PATCH 01/23] Add initial draft of hierarchical accounts api --- ERCS/erc-draft-hierarchical-accounts-api.md | 236 ++++++++++++++++++++ 1 file changed, 236 insertions(+) create mode 100644 ERCS/erc-draft-hierarchical-accounts-api.md diff --git a/ERCS/erc-draft-hierarchical-accounts-api.md b/ERCS/erc-draft-hierarchical-accounts-api.md new file mode 100644 index 00000000000..d8dccf3ded1 --- /dev/null +++ b/ERCS/erc-draft-hierarchical-accounts-api.md @@ -0,0 +1,236 @@ +--- +title: API for hierarchical accounts +description: Adds JSON-RPC method for requesting a universal wallet to create or track another account that it owns +authors: Wilson Cusack (@wilsoncusack), Jake Feldman (@jakefeldman), Montana Wong (@montycheese), Felix Zhang (@fan-zhang-sv) +discussions-to: tbd +status: Draft +type: Standards Track +category: ERC +created: 2025-02-18 +--- + +## Abstract + +This ERC introduces a new wallet RPC, wallet_addSubAccount, which allows an app to request a wallet to track a smart account that the wallet owns. It also allows apps to request the wallet to provision a new account, owned by the universal wallet with a signer provided by the caller. + + +## Motivation + +Embedded app accounts (onchain accounts specific to a single app) have led to a proliferation of user addresses, which can be difficult for users to keep track of. Many embedded app account users also have a universal wallet, which can be used across apps. With hierarchical ownership–where one smart account can own another–if the embedded app account is a smart account, it could be owned by the user’s universal wallet. This would allow users to be able to control an app account via their universal wallet. However, though hierarchical ownership is already possible today, there is no way for apps to tell universal wallets about embedded app accounts a user may have. The proposed RPC provides a path for this. + +## Specification + +### Definitions +Account - In this document, “account” means smart account. A smart contract that users transact from. +Sub Account - An account that SHOULD have the main account as an owner of the sub-account. For instance, Account B is a sub-account of Account A if Account A is an owner, i.e. is a signer for Account B. + +The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 and RFC 8174. + +### JSON-RPC Methods + +#### `wallet_addSubAccount` + +The wallet_addSubAccount RPC method allows applications to request that the connected account tracks the app account, creating a hierarchy between a universal account and app-embedded accounts. This RPC supports three different use cases. + +##### Request + +```typescript +// Previously deployed account, i.e. wallet "imports" account +type DeployedAccount = { + type: "deployed"; + // Required: address of the account + address: `0x${string}`; + keys: never; + chainId?: '0x{string}'; + factory?: never; + factoryData?: never; +} + +// Requester is agnostic to account type and only wants to ensure its signer is an owner +type CreateAccount = { + type: "create"; + keys: { + type: "address" | "p256" | "webcrypto-p256" | "webauthn-p256"; + key: "0x..."; + }[]; +} + +// Undeployed account, app creates the account +type UndeployedAccount = { + type: "undeployed"; + address: never; + keys: never; + chainId?: '0x{string}'; // in Hex + // Required: factory address to create the account + factory: `0x${string}`; + // Required: factory calldata for the account + factoryData: `0x${string}`; +} + +type Request = { + method: "wallet_addSubAccount"; + params: [{ + // JSON-RPC method version + version: string; + // JSON-RPC method account + account: CreateAccount | DeployedAccount | UndeployedAccount; + }], +} +``` + +##### Response + +Factory data and factory address are OPTIONAL and SHOULD be returned when available. Deployed accounts MAY not have these fields. + +```typescript +type Response = { + // Address of the account. + address: `0x${string}`; + // Optional: factory address + factory?: `0x${string}`; + // Optional: factory calldata + factoryData?: `0x${string}`; +} +``` + +##### `CreateAccount` + +Allows the wallet to create a Sub Account with a list of known signers. This enables applications to provide a signer for the new account. A wallet SHOULD make the universal account an owner of the account, creating a hierarchical relationship between the newly created account and the universal account. + +```typescript +type Parameters = { + address: never; + // Required: keys of the account to be created + keys: { + type: "address" | "p256" | "webcrypto-p256" | "webauthn-p256"; + key: "0x..."; + }[]; + factory: never; + factoryData: never; +} +``` + +##### UndeployedAccount + +An undeployed account is an account that an application has created, but has not yet deployed.. The wallet can decide whether or not it is appropriate to deploy it. Wallets SHOULD validate that the universal account is an owner. Either through decoding the factoryData or simulating the deployment that there is a hierarchy between the universal account and newly created account. + +Example: the application creates an account and generates the counterfactual address for the user to airdrop funds to. Once there is an account relationship with the universal account, the user wishes to perform a transaction, in which the wallet will deploy the account in order to execute the respective transaction. + +```typescript +type Parameters = { + // Required: address of the account + address: `0x${string}`; + signers: never; + factory: never; + factoryData: never; +} +``` + +##### `DeployedAccount` + +An existing account could be any smart that an app or user wants to track via their universal wallet. + +Example: The user wants to define a hierarchical relationship between an existing app account and their universal wallet. + +```typescript +// Previously deployed account "import" +type Parameters = { + // Required: address of the account + address: `0x${string}`; + signers: never; + factory: never; + factoryData: never; +} +``` + +### External RPC Capabilities + +#### `wallet_connect` + +This ERC conforms to [EIP 7846] (https://eip.tools/eip/7846) which includes [EIP5792](https://eip.tools/eip/5792) capabilities specification and introduces two new capabilities for wallet_connect. + +##### addSubAccount + +```typescript +type Request = { + addSubAccount: { + account: CreateAccount | DeployedAccount | UndeployedAccount; + } +} + +type Response = { + addSubAccount: { + address: `0x${string}`; + } +} +``` + +##### `getSubAccounts` + +```typescript +type Request = { + getSubAccounts: boolean; +} + +type Response = { + getSubAccounts: { + address: `0x${string}`; + factory?: `0x${string}`; + factoryData?: `0x${string}`; + }[]; +} +``` + +#### wallet_getCapabilities + +This ERC conforms with wallet_getCapabilities [ERC-5792](https://eips.ethereum.org/EIPS/eip-5792#wallet_getcapabilities). The response will accommodate addSubAccount support for wallets that support it. + +```typescript +type Response = { + addSubAccount: { + supported: true, + keyTypes: ("address" | "p256" | "webcrypto-p256" | "webauthn-p256")[]; + } +} + + +// Example +const response = { + "0x2105": { + "addSubAccount": { + "supported": true, + "keyTypes": ["address", "webauthn-p256"]; + }, + }, + "0x14A34": { + "addSubAccount": { + "supported": true, + "keyTypes": ["address", "webauthn-p256"]; + }, + } +} +``` + +## Rationale + +### Naming + +Initial intent was to leverage existing RPCs, like `wallet_connect` (e.g. [EIP 7846] (https://eips.ethereum.org/EIPS/eip-7846)) with additional capabilities to add support for these new features, but these methods ultimately lacked flexibility. Then there were custom namespaced RPCs but this resulted with more fragmentation within the community. + +Method names explored `wallet_linkAccount`, `wallet_importAddress`, `wallet_addAddress`, or something else. Multiple RPCs were explored as well, separating create and tracking as two separate RPCs. To consolidate on a single RPC `wallet_addSubAccount` was selected. This method is more inclusive for EOA use cases. + +## Backwards Compatibility + +This standard builds on existing JSON-RPC methods and complements [ERC-5792](https://eips.ethereum.org/EIPS/eip-5792#wallet_getcapabilities) for future extensibility. Wallets can continue supporting legacy methods. + +## Security Considerations + +As more capabilities are added, care should be taken to avoid unpredictable interactions. App specific accounts pose more risk for assets in those accounts. Having a universal account that maintains access to these accounts gives additional security to users and their funds. + +## Privacy Considerations + +Account data and any shared capabilities must be handled securely to avoid data leaks or man-in-the-middle attacks. + +## Copyright + +Copyright and related rights waived via CC0. From b22e5636418201a5b23730743c1b226c130ba3e1 Mon Sep 17 00:00:00 2001 From: jakeFeldman Date: Thu, 27 Feb 2025 12:51:42 -0700 Subject: [PATCH 02/23] update discussions-to link --- ERCS/erc-draft-hierarchical-accounts-api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ERCS/erc-draft-hierarchical-accounts-api.md b/ERCS/erc-draft-hierarchical-accounts-api.md index d8dccf3ded1..13cec1950a4 100644 --- a/ERCS/erc-draft-hierarchical-accounts-api.md +++ b/ERCS/erc-draft-hierarchical-accounts-api.md @@ -2,7 +2,7 @@ title: API for hierarchical accounts description: Adds JSON-RPC method for requesting a universal wallet to create or track another account that it owns authors: Wilson Cusack (@wilsoncusack), Jake Feldman (@jakefeldman), Montana Wong (@montycheese), Felix Zhang (@fan-zhang-sv) -discussions-to: tbd +discussions-to: https://ethereum-magicians.org/t/wallet-addsubaccount/23013 status: Draft type: Standards Track category: ERC From c45ed5878c810daa92a4ee3551a9ac030e6d4468 Mon Sep 17 00:00:00 2001 From: Sam Wilson <57262657+SamWilsn@users.noreply.github.com> Date: Mon, 3 Mar 2025 09:28:12 -0500 Subject: [PATCH 03/23] Update and rename erc-draft-hierarchical-accounts-api.md to erc-7896.md --- ERCS/{erc-draft-hierarchical-accounts-api.md => erc-7896.md} | 1 + 1 file changed, 1 insertion(+) rename ERCS/{erc-draft-hierarchical-accounts-api.md => erc-7896.md} (99%) diff --git a/ERCS/erc-draft-hierarchical-accounts-api.md b/ERCS/erc-7896.md similarity index 99% rename from ERCS/erc-draft-hierarchical-accounts-api.md rename to ERCS/erc-7896.md index 13cec1950a4..e9219c48024 100644 --- a/ERCS/erc-draft-hierarchical-accounts-api.md +++ b/ERCS/erc-7896.md @@ -1,4 +1,5 @@ --- +eip: 7896 title: API for hierarchical accounts description: Adds JSON-RPC method for requesting a universal wallet to create or track another account that it owns authors: Wilson Cusack (@wilsoncusack), Jake Feldman (@jakefeldman), Montana Wong (@montycheese), Felix Zhang (@fan-zhang-sv) From c1f0ea1ff1066ed5403dc56af6827d27391690e8 Mon Sep 17 00:00:00 2001 From: Sam Wilson <57262657+SamWilsn@users.noreply.github.com> Date: Mon, 3 Mar 2025 09:31:11 -0500 Subject: [PATCH 04/23] Update and rename erc-7896.md to erc-7895.md --- ERCS/{erc-7896.md => erc-7895.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename ERCS/{erc-7896.md => erc-7895.md} (99%) diff --git a/ERCS/erc-7896.md b/ERCS/erc-7895.md similarity index 99% rename from ERCS/erc-7896.md rename to ERCS/erc-7895.md index e9219c48024..55e319de7ac 100644 --- a/ERCS/erc-7896.md +++ b/ERCS/erc-7895.md @@ -1,5 +1,5 @@ --- -eip: 7896 +eip: 7895 title: API for hierarchical accounts description: Adds JSON-RPC method for requesting a universal wallet to create or track another account that it owns authors: Wilson Cusack (@wilsoncusack), Jake Feldman (@jakefeldman), Montana Wong (@montycheese), Felix Zhang (@fan-zhang-sv) From 722f1f35db59b9cd050817af36e95dbf22e6af11 Mon Sep 17 00:00:00 2001 From: jakeFeldman Date: Mon, 3 Mar 2025 14:06:45 -0700 Subject: [PATCH 05/23] fix links --- ERCS/erc-7895.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ERCS/erc-7895.md b/ERCS/erc-7895.md index 55e319de7ac..682d90f6a12 100644 --- a/ERCS/erc-7895.md +++ b/ERCS/erc-7895.md @@ -12,7 +12,7 @@ created: 2025-02-18 ## Abstract -This ERC introduces a new wallet RPC, wallet_addSubAccount, which allows an app to request a wallet to track a smart account that the wallet owns. It also allows apps to request the wallet to provision a new account, owned by the universal wallet with a signer provided by the caller. +This ERC introduces a new wallet RPC, `wallet_addSubAccount`, which allows an app to request a wallet to track a smart account that the wallet owns. It also allows apps to request the wallet to provision a new account, owned by the universal wallet with a signer provided by the caller. ## Motivation @@ -31,7 +31,7 @@ The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "S #### `wallet_addSubAccount` -The wallet_addSubAccount RPC method allows applications to request that the connected account tracks the app account, creating a hierarchy between a universal account and app-embedded accounts. This RPC supports three different use cases. +The `wallet_addSubAccount` RPC method allows applications to request that the connected account tracks the app account, creating a hierarchy between a universal account and app-embedded accounts. This RPC supports three different use cases. ##### Request @@ -148,7 +148,7 @@ type Parameters = { #### `wallet_connect` -This ERC conforms to [EIP 7846] (https://eip.tools/eip/7846) which includes [EIP5792](https://eip.tools/eip/5792) capabilities specification and introduces two new capabilities for wallet_connect. +This ERC conforms to [ERC-7846](./erc-7846.md) which includes [ERC-5792](./erc-5792.md) capabilities specification and introduces two new capabilities for `wallet_connect`. ##### addSubAccount @@ -182,9 +182,9 @@ type Response = { } ``` -#### wallet_getCapabilities +#### `wallet_getCapabilities` -This ERC conforms with wallet_getCapabilities [ERC-5792](https://eips.ethereum.org/EIPS/eip-5792#wallet_getcapabilities). The response will accommodate addSubAccount support for wallets that support it. +This ERC conforms with `wallet_getCapabilities` [ERC-5792](./erc-5792.md). The response will accommodate addSubAccount support for wallets that support it. ```typescript type Response = { @@ -216,13 +216,13 @@ const response = { ### Naming -Initial intent was to leverage existing RPCs, like `wallet_connect` (e.g. [EIP 7846] (https://eips.ethereum.org/EIPS/eip-7846)) with additional capabilities to add support for these new features, but these methods ultimately lacked flexibility. Then there were custom namespaced RPCs but this resulted with more fragmentation within the community. +Initial intent was to leverage existing RPCs, like `wallet_connect` (e.g. [ERC-7846](./erc-7846.md)) with additional capabilities to add support for these new features, but these methods ultimately lacked flexibility. Then there were custom namespaced RPCs but this resulted with more fragmentation within the community. Method names explored `wallet_linkAccount`, `wallet_importAddress`, `wallet_addAddress`, or something else. Multiple RPCs were explored as well, separating create and tracking as two separate RPCs. To consolidate on a single RPC `wallet_addSubAccount` was selected. This method is more inclusive for EOA use cases. ## Backwards Compatibility -This standard builds on existing JSON-RPC methods and complements [ERC-5792](https://eips.ethereum.org/EIPS/eip-5792#wallet_getcapabilities) for future extensibility. Wallets can continue supporting legacy methods. +This standard builds on existing JSON-RPC methods and complements [ERC-5792](./erc-5792.md) for future extensibility. Wallets can continue supporting legacy methods. ## Security Considerations From bd8b6332a38c2279a7920df7656b50d256e42730 Mon Sep 17 00:00:00 2001 From: jakeFeldman Date: Mon, 3 Mar 2025 14:08:48 -0700 Subject: [PATCH 06/23] fix header --- ERCS/erc-7895.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ERCS/erc-7895.md b/ERCS/erc-7895.md index 682d90f6a12..9f6b1f2a0ad 100644 --- a/ERCS/erc-7895.md +++ b/ERCS/erc-7895.md @@ -2,7 +2,7 @@ eip: 7895 title: API for hierarchical accounts description: Adds JSON-RPC method for requesting a universal wallet to create or track another account that it owns -authors: Wilson Cusack (@wilsoncusack), Jake Feldman (@jakefeldman), Montana Wong (@montycheese), Felix Zhang (@fan-zhang-sv) +author: Wilson Cusack (@wilsoncusack), Jake Feldman (@jakefeldman), Montana Wong (@montycheese), Felix Zhang (@fan-zhang-sv) discussions-to: https://ethereum-magicians.org/t/wallet-addsubaccount/23013 status: Draft type: Standards Track From 3aeb0caad0c6248247b46184c920aeeb015cb0cc Mon Sep 17 00:00:00 2001 From: jakeFeldman Date: Mon, 3 Mar 2025 14:12:17 -0700 Subject: [PATCH 07/23] update title --- ERCS/erc-7895.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ERCS/erc-7895.md b/ERCS/erc-7895.md index 9f6b1f2a0ad..933d67ac4cf 100644 --- a/ERCS/erc-7895.md +++ b/ERCS/erc-7895.md @@ -228,7 +228,7 @@ This standard builds on existing JSON-RPC methods and complements [ERC-5792](./e As more capabilities are added, care should be taken to avoid unpredictable interactions. App specific accounts pose more risk for assets in those accounts. Having a universal account that maintains access to these accounts gives additional security to users and their funds. -## Privacy Considerations +### Privacy Considerations Account data and any shared capabilities must be handled securely to avoid data leaks or man-in-the-middle attacks. From 58f278483c532d0359f3bead8f677eff3cce2c69 Mon Sep 17 00:00:00 2001 From: jakeFeldman Date: Tue, 4 Mar 2025 12:49:19 -0700 Subject: [PATCH 08/23] update links --- ERCS/erc-7895.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ERCS/erc-7895.md b/ERCS/erc-7895.md index 933d67ac4cf..4de5f7075a2 100644 --- a/ERCS/erc-7895.md +++ b/ERCS/erc-7895.md @@ -148,7 +148,7 @@ type Parameters = { #### `wallet_connect` -This ERC conforms to [ERC-7846](./erc-7846.md) which includes [ERC-5792](./erc-5792.md) capabilities specification and introduces two new capabilities for `wallet_connect`. +This ERC conforms to [ERC-7846](https://eip.tools/eip/7846) which includes [ERC-5792](https://eip.tools/eip/5792) capabilities specification and introduces two new capabilities for `wallet_connect`. ##### addSubAccount @@ -184,7 +184,7 @@ type Response = { #### `wallet_getCapabilities` -This ERC conforms with `wallet_getCapabilities` [ERC-5792](./erc-5792.md). The response will accommodate addSubAccount support for wallets that support it. +This ERC conforms with `wallet_getCapabilities` [ERC-5792](https://eip.tools/eip/5792). The response will accommodate addSubAccount support for wallets that support it. ```typescript type Response = { @@ -216,13 +216,13 @@ const response = { ### Naming -Initial intent was to leverage existing RPCs, like `wallet_connect` (e.g. [ERC-7846](./erc-7846.md)) with additional capabilities to add support for these new features, but these methods ultimately lacked flexibility. Then there were custom namespaced RPCs but this resulted with more fragmentation within the community. +Initial intent was to leverage existing RPCs, like `wallet_connect` (e.g. [ERC-7846](https://eip.tools/eip/7846)) with additional capabilities to add support for these new features, but these methods ultimately lacked flexibility. Then there were custom namespaced RPCs but this resulted with more fragmentation within the community. Method names explored `wallet_linkAccount`, `wallet_importAddress`, `wallet_addAddress`, or something else. Multiple RPCs were explored as well, separating create and tracking as two separate RPCs. To consolidate on a single RPC `wallet_addSubAccount` was selected. This method is more inclusive for EOA use cases. ## Backwards Compatibility -This standard builds on existing JSON-RPC methods and complements [ERC-5792](./erc-5792.md) for future extensibility. Wallets can continue supporting legacy methods. +This standard builds on existing JSON-RPC methods and complements [ERC-5792](https://eip.tools/eip/5792) for future extensibility. Wallets can continue supporting legacy methods. ## Security Considerations From 5f9d9347357e9d8af6d46b6f79dd8f122ccef300 Mon Sep 17 00:00:00 2001 From: jakeFeldman Date: Tue, 4 Mar 2025 13:45:03 -0700 Subject: [PATCH 09/23] links --- ERCS/erc-7895.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ERCS/erc-7895.md b/ERCS/erc-7895.md index 4de5f7075a2..efc9258f313 100644 --- a/ERCS/erc-7895.md +++ b/ERCS/erc-7895.md @@ -148,7 +148,7 @@ type Parameters = { #### `wallet_connect` -This ERC conforms to [ERC-7846](https://eip.tools/eip/7846) which includes [ERC-5792](https://eip.tools/eip/5792) capabilities specification and introduces two new capabilities for `wallet_connect`. +This ERC conforms to [ERC-7846](https://eips.ethereum.org/EIPS/eip-7846) which includes [ERC-5792](https://eips.ethereum.org/EIPS/eip-5792) capabilities specification and introduces two new capabilities for `wallet_connect`. ##### addSubAccount @@ -184,7 +184,7 @@ type Response = { #### `wallet_getCapabilities` -This ERC conforms with `wallet_getCapabilities` [ERC-5792](https://eip.tools/eip/5792). The response will accommodate addSubAccount support for wallets that support it. +This ERC conforms with `wallet_getCapabilities` [ERC-5792](https://eips.ethereum.org/EIPS/eip-5792). The response will accommodate addSubAccount support for wallets that support it. ```typescript type Response = { @@ -216,13 +216,13 @@ const response = { ### Naming -Initial intent was to leverage existing RPCs, like `wallet_connect` (e.g. [ERC-7846](https://eip.tools/eip/7846)) with additional capabilities to add support for these new features, but these methods ultimately lacked flexibility. Then there were custom namespaced RPCs but this resulted with more fragmentation within the community. +Initial intent was to leverage existing RPCs, like `wallet_connect` (e.g. [ERC-7846](https://eips.ethereum.org/EIPS/eip-7846)) with additional capabilities to add support for these new features, but these methods ultimately lacked flexibility. Then there were custom namespaced RPCs but this resulted with more fragmentation within the community. Method names explored `wallet_linkAccount`, `wallet_importAddress`, `wallet_addAddress`, or something else. Multiple RPCs were explored as well, separating create and tracking as two separate RPCs. To consolidate on a single RPC `wallet_addSubAccount` was selected. This method is more inclusive for EOA use cases. ## Backwards Compatibility -This standard builds on existing JSON-RPC methods and complements [ERC-5792](https://eip.tools/eip/5792) for future extensibility. Wallets can continue supporting legacy methods. +This standard builds on existing JSON-RPC methods and complements [ERC-5792](https://eips.ethereum.org/EIPS/eip-5792) for future extensibility. Wallets can continue supporting legacy methods. ## Security Considerations From 6ff4467dedad9c11157f2a8a2bd395926c3fb5fd Mon Sep 17 00:00:00 2001 From: jakeFeldman Date: Wed, 5 Mar 2025 10:12:28 -0700 Subject: [PATCH 10/23] links --- ERCS/erc-7895.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ERCS/erc-7895.md b/ERCS/erc-7895.md index efc9258f313..95f5f852d87 100644 --- a/ERCS/erc-7895.md +++ b/ERCS/erc-7895.md @@ -148,7 +148,7 @@ type Parameters = { #### `wallet_connect` -This ERC conforms to [ERC-7846](https://eips.ethereum.org/EIPS/eip-7846) which includes [ERC-5792](https://eips.ethereum.org/EIPS/eip-5792) capabilities specification and introduces two new capabilities for `wallet_connect`. +This ERC conforms to ERC-7846 which includes [ERC-5792](./erc-5792.md) capabilities specification and introduces two new capabilities for `wallet_connect`. ##### addSubAccount @@ -184,7 +184,7 @@ type Response = { #### `wallet_getCapabilities` -This ERC conforms with `wallet_getCapabilities` [ERC-5792](https://eips.ethereum.org/EIPS/eip-5792). The response will accommodate addSubAccount support for wallets that support it. +This ERC conforms with `wallet_getCapabilities` [ERC-5792](./erc-5792.md). The response will accommodate addSubAccount support for wallets that support it. ```typescript type Response = { @@ -216,13 +216,13 @@ const response = { ### Naming -Initial intent was to leverage existing RPCs, like `wallet_connect` (e.g. [ERC-7846](https://eips.ethereum.org/EIPS/eip-7846)) with additional capabilities to add support for these new features, but these methods ultimately lacked flexibility. Then there were custom namespaced RPCs but this resulted with more fragmentation within the community. +Initial intent was to leverage existing RPCs, like `wallet_connect` (e.g. ERC-7846 with additional capabilities to add support for these new features, but these methods ultimately lacked flexibility. Then there were custom namespaced RPCs but this resulted with more fragmentation within the community. Method names explored `wallet_linkAccount`, `wallet_importAddress`, `wallet_addAddress`, or something else. Multiple RPCs were explored as well, separating create and tracking as two separate RPCs. To consolidate on a single RPC `wallet_addSubAccount` was selected. This method is more inclusive for EOA use cases. ## Backwards Compatibility -This standard builds on existing JSON-RPC methods and complements [ERC-5792](https://eips.ethereum.org/EIPS/eip-5792) for future extensibility. Wallets can continue supporting legacy methods. +This standard builds on existing JSON-RPC methods and complements [ERC-5792](./erc-5792.md) for future extensibility. Wallets can continue supporting legacy methods. ## Security Considerations From b5cfaf7ebcb4152e53fa33031aa998836eb05150 Mon Sep 17 00:00:00 2001 From: jakeFeldman Date: Fri, 7 Mar 2025 10:06:57 -0700 Subject: [PATCH 11/23] fix typo in types --- ERCS/erc-7895.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ERCS/erc-7895.md b/ERCS/erc-7895.md index 95f5f852d87..8eb6eed2b31 100644 --- a/ERCS/erc-7895.md +++ b/ERCS/erc-7895.md @@ -121,7 +121,7 @@ Example: the application creates an account and generates the counterfactual add type Parameters = { // Required: address of the account address: `0x${string}`; - signers: never; + keys: never; factory: never; factoryData: never; } @@ -138,7 +138,7 @@ Example: The user wants to define a hierarchical relationship between an existin type Parameters = { // Required: address of the account address: `0x${string}`; - signers: never; + keys: never; factory: never; factoryData: never; } @@ -148,7 +148,7 @@ type Parameters = { #### `wallet_connect` -This ERC conforms to ERC-7846 which includes [ERC-5792](./erc-5792.md) capabilities specification and introduces two new capabilities for `wallet_connect`. +This ERC conforms to ERC 7846 which includes [ERC-5792](./erc-5792.md) capabilities specification and introduces two new capabilities for `wallet_connect`. ##### addSubAccount @@ -216,7 +216,7 @@ const response = { ### Naming -Initial intent was to leverage existing RPCs, like `wallet_connect` (e.g. ERC-7846 with additional capabilities to add support for these new features, but these methods ultimately lacked flexibility. Then there were custom namespaced RPCs but this resulted with more fragmentation within the community. +Initial intent was to leverage existing RPCs, like `wallet_connect` (e.g. ERC 7846 with additional capabilities to add support for these new features, but these methods ultimately lacked flexibility. Then there were custom namespaced RPCs but this resulted with more fragmentation within the community. Method names explored `wallet_linkAccount`, `wallet_importAddress`, `wallet_addAddress`, or something else. Multiple RPCs were explored as well, separating create and tracking as two separate RPCs. To consolidate on a single RPC `wallet_addSubAccount` was selected. This method is more inclusive for EOA use cases. From 3d950152b5e3765208b0d63aa5c92f70a07a0cc7 Mon Sep 17 00:00:00 2001 From: jakeFeldman Date: Tue, 11 Mar 2025 10:58:41 -0600 Subject: [PATCH 12/23] update type --- ERCS/erc-7895.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ERCS/erc-7895.md b/ERCS/erc-7895.md index 8eb6eed2b31..3403ba453a9 100644 --- a/ERCS/erc-7895.md +++ b/ERCS/erc-7895.md @@ -59,7 +59,7 @@ type CreateAccount = { // Undeployed account, app creates the account type UndeployedAccount = { type: "undeployed"; - address: never; + address: `0x${string}`; keys: never; chainId?: '0x{string}'; // in Hex // Required: factory address to create the account From 4d3d641ee3c84750baf461b8dd71d27c424417a9 Mon Sep 17 00:00:00 2001 From: Sam Wilson <57262657+SamWilsn@users.noreply.github.com> Date: Thu, 13 Mar 2025 06:32:36 -0400 Subject: [PATCH 13/23] Apply suggestions from code review Co-authored-by: Mercy Boma Naps Nkari <96525594+bomanaps@users.noreply.github.com> --- ERCS/erc-7895.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ERCS/erc-7895.md b/ERCS/erc-7895.md index 3403ba453a9..12bd692a035 100644 --- a/ERCS/erc-7895.md +++ b/ERCS/erc-7895.md @@ -148,7 +148,7 @@ type Parameters = { #### `wallet_connect` -This ERC conforms to ERC 7846 which includes [ERC-5792](./erc-5792.md) capabilities specification and introduces two new capabilities for `wallet_connect`. +This ERC conforms to ERC-7846 which includes [ERC-5792](./erc-5792.md) capabilities specification and introduces two new capabilities for `wallet_connect`. ##### addSubAccount @@ -216,7 +216,7 @@ const response = { ### Naming -Initial intent was to leverage existing RPCs, like `wallet_connect` (e.g. ERC 7846 with additional capabilities to add support for these new features, but these methods ultimately lacked flexibility. Then there were custom namespaced RPCs but this resulted with more fragmentation within the community. +Initial intent was to leverage existing RPCs, like `wallet_connect` (e.g. ERC-7846 with additional capabilities to add support for these new features, but these methods ultimately lacked flexibility. Then there were custom namespaced RPCs but this resulted with more fragmentation within the community. Method names explored `wallet_linkAccount`, `wallet_importAddress`, `wallet_addAddress`, or something else. Multiple RPCs were explored as well, separating create and tracking as two separate RPCs. To consolidate on a single RPC `wallet_addSubAccount` was selected. This method is more inclusive for EOA use cases. From 8875ce79af9f47554fdf1f1a5a3e2ea6be4a8715 Mon Sep 17 00:00:00 2001 From: jxom <7336481+jxom@users.noreply.github.com> Date: Mon, 5 May 2025 10:06:49 +1000 Subject: [PATCH 14/23] chore: tweaks --- ERCS/erc-7895.md | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/ERCS/erc-7895.md b/ERCS/erc-7895.md index 12bd692a035..15cf88f4622 100644 --- a/ERCS/erc-7895.md +++ b/ERCS/erc-7895.md @@ -2,7 +2,7 @@ eip: 7895 title: API for hierarchical accounts description: Adds JSON-RPC method for requesting a universal wallet to create or track another account that it owns -author: Wilson Cusack (@wilsoncusack), Jake Feldman (@jakefeldman), Montana Wong (@montycheese), Felix Zhang (@fan-zhang-sv) +author: Wilson Cusack (@wilsoncusack), Jake Feldman (@jakefeldman), Montana Wong (@montycheese), Felix Zhang (@fan-zhang-sv), Jake Moxey (@jxom) discussions-to: https://ethereum-magicians.org/t/wallet-addsubaccount/23013 status: Draft type: Standards Track @@ -51,8 +51,8 @@ type DeployedAccount = { type CreateAccount = { type: "create"; keys: { + publicKey: "0x..."; type: "address" | "p256" | "webcrypto-p256" | "webauthn-p256"; - key: "0x..."; }[]; } @@ -103,8 +103,8 @@ type Parameters = { address: never; // Required: keys of the account to be created keys: { + publicKey: "0x..."; type: "address" | "p256" | "webcrypto-p256" | "webauthn-p256"; - key: "0x..."; }[]; factory: never; factoryData: never; @@ -150,7 +150,9 @@ type Parameters = { This ERC conforms to ERC-7846 which includes [ERC-5792](./erc-5792.md) capabilities specification and introduces two new capabilities for `wallet_connect`. -##### addSubAccount +##### `addSubAccount` + +Adds a sub-account to the universal account. ```typescript type Request = { @@ -158,23 +160,15 @@ type Request = { account: CreateAccount | DeployedAccount | UndeployedAccount; } } - -type Response = { - addSubAccount: { - address: `0x${string}`; - } -} ``` -##### `getSubAccounts` +##### `subAccounts` -```typescript -type Request = { - getSubAccounts: boolean; -} +Fetches all sub-accounts of the universal account (including any added ones). +```typescript type Response = { - getSubAccounts: { + subAccounts: { address: `0x${string}`; factory?: `0x${string}`; factoryData?: `0x${string}`; From 3c88d3562ea3cbd79bb5e484d848bcbb0968cd4e Mon Sep 17 00:00:00 2001 From: Jacob Feldman <25087876+jakeFeldman@users.noreply.github.com> Date: Mon, 5 May 2025 10:22:26 -0600 Subject: [PATCH 15/23] Update ERCS/erc-7895.md Co-authored-by: Sam Wilson <57262657+SamWilsn@users.noreply.github.com> --- ERCS/erc-7895.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ERCS/erc-7895.md b/ERCS/erc-7895.md index 12bd692a035..e631aff6ebd 100644 --- a/ERCS/erc-7895.md +++ b/ERCS/erc-7895.md @@ -22,11 +22,11 @@ Embedded app accounts (onchain accounts specific to a single app) have led to a ## Specification ### Definitions +The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 and RFC 8174. + Account - In this document, “account” means smart account. A smart contract that users transact from. Sub Account - An account that SHOULD have the main account as an owner of the sub-account. For instance, Account B is a sub-account of Account A if Account A is an owner, i.e. is a signer for Account B. -The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 and RFC 8174. - ### JSON-RPC Methods #### `wallet_addSubAccount` From 9b2d966c6bf5eb65c27c20fc1f7f95948bf4bcd9 Mon Sep 17 00:00:00 2001 From: Jacob Feldman <25087876+jakeFeldman@users.noreply.github.com> Date: Mon, 5 May 2025 10:22:32 -0600 Subject: [PATCH 16/23] Update ERCS/erc-7895.md Co-authored-by: Sam Wilson <57262657+SamWilsn@users.noreply.github.com> --- ERCS/erc-7895.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ERCS/erc-7895.md b/ERCS/erc-7895.md index e631aff6ebd..57fe8980362 100644 --- a/ERCS/erc-7895.md +++ b/ERCS/erc-7895.md @@ -234,4 +234,4 @@ Account data and any shared capabilities must be handled securely to avoid data ## Copyright -Copyright and related rights waived via CC0. +Copyright and related rights waived via [CC0](../LICENSE.md). From bcfac6c792416699f0efb7371785b83fa09acbab Mon Sep 17 00:00:00 2001 From: Jacob Feldman <25087876+jakeFeldman@users.noreply.github.com> Date: Thu, 8 May 2025 11:06:29 -0600 Subject: [PATCH 17/23] Update ERCS/erc-7895.md Co-authored-by: jxom <7336481+jxom@users.noreply.github.com> --- ERCS/erc-7895.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ERCS/erc-7895.md b/ERCS/erc-7895.md index 359c793f86a..06682a9bd5b 100644 --- a/ERCS/erc-7895.md +++ b/ERCS/erc-7895.md @@ -96,20 +96,19 @@ type Response = { ##### `CreateAccount` -Allows the wallet to create a Sub Account with a list of known signers. This enables applications to provide a signer for the new account. A wallet SHOULD make the universal account an owner of the account, creating a hierarchical relationship between the newly created account and the universal account. +Creates a new Sub Account. By default, if no signing keys (`keys`) are provided, the Sub Account's signing key MUST be created & managed by the wallet. However, an application MAY optionally provide a set of signing keys (`keys`) for the Sub Account. A wallet SHOULD make the universal account an owner of the account, creating a hierarchical relationship between the newly created account and the universal account. ```typescript type Parameters = { address: never; - // Required: keys of the account to be created - keys: { + // Optional: keys of the account to be created + keys?: { publicKey: "0x..."; type: "address" | "p256" | "webcrypto-p256" | "webauthn-p256"; }[]; factory: never; factoryData: never; } -``` ##### UndeployedAccount From 54ceaf46a2b403d68a898f603c80493a1904520a Mon Sep 17 00:00:00 2001 From: Sam Wilson <57262657+SamWilsn@users.noreply.github.com> Date: Mon, 30 Jun 2025 15:10:20 -0400 Subject: [PATCH 18/23] Update erc-7895.md --- ERCS/erc-7895.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ERCS/erc-7895.md b/ERCS/erc-7895.md index 06682a9bd5b..863ec612c8a 100644 --- a/ERCS/erc-7895.md +++ b/ERCS/erc-7895.md @@ -1,7 +1,7 @@ --- eip: 7895 -title: API for hierarchical accounts -description: Adds JSON-RPC method for requesting a universal wallet to create or track another account that it owns +title: API for Hierarchical Accounts +description: Adds JSON-RPC method for requesting that a universal wallet create or track another account that it owns author: Wilson Cusack (@wilsoncusack), Jake Feldman (@jakefeldman), Montana Wong (@montycheese), Felix Zhang (@fan-zhang-sv), Jake Moxey (@jxom) discussions-to: https://ethereum-magicians.org/t/wallet-addsubaccount/23013 status: Draft From 9fec4783ab3055dd7fec006bd5561a35c3a129bf Mon Sep 17 00:00:00 2001 From: Sam Wilson <57262657+SamWilsn@users.noreply.github.com> Date: Mon, 30 Jun 2025 15:10:43 -0400 Subject: [PATCH 19/23] Update erc-7895.md --- ERCS/erc-7895.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ERCS/erc-7895.md b/ERCS/erc-7895.md index 863ec612c8a..e39840be4b6 100644 --- a/ERCS/erc-7895.md +++ b/ERCS/erc-7895.md @@ -12,7 +12,7 @@ created: 2025-02-18 ## Abstract -This ERC introduces a new wallet RPC, `wallet_addSubAccount`, which allows an app to request a wallet to track a smart account that the wallet owns. It also allows apps to request the wallet to provision a new account, owned by the universal wallet with a signer provided by the caller. +This ERC introduces a new wallet RPC, `wallet_addSubAccount`, which allows an app to request a wallet track a smart account that the wallet owns. It also allows apps to request the wallet to provision a new account, owned by the universal wallet with a signer provided by the caller. ## Motivation From 00bbc5bf17c2356abd9d59392ec0a0b8b0017a3b Mon Sep 17 00:00:00 2001 From: Sam Wilson <57262657+SamWilsn@users.noreply.github.com> Date: Mon, 30 Jun 2025 15:25:37 -0400 Subject: [PATCH 20/23] Update erc-7895.md --- ERCS/erc-7895.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ERCS/erc-7895.md b/ERCS/erc-7895.md index e39840be4b6..efbe4fd373e 100644 --- a/ERCS/erc-7895.md +++ b/ERCS/erc-7895.md @@ -109,6 +109,7 @@ type Parameters = { factory: never; factoryData: never; } +``` ##### UndeployedAccount From fa70447dbade25a2210520dc76ad1bf401cbeb83 Mon Sep 17 00:00:00 2001 From: Sam Wilson <57262657+SamWilsn@users.noreply.github.com> Date: Mon, 30 Jun 2025 15:28:53 -0400 Subject: [PATCH 21/23] Update erc-7895.md --- ERCS/erc-7895.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ERCS/erc-7895.md b/ERCS/erc-7895.md index efbe4fd373e..d14c739a760 100644 --- a/ERCS/erc-7895.md +++ b/ERCS/erc-7895.md @@ -148,7 +148,7 @@ type Parameters = { #### `wallet_connect` -This ERC conforms to ERC-7846 which includes [ERC-5792](./erc-5792.md) capabilities specification and introduces two new capabilities for `wallet_connect`. +This ERC conforms to which includes [ERC-5792](./erc-5792.md) capabilities specification and introduces two new capabilities for `wallet_connect`. ##### `addSubAccount` From acf2ee202b0acb233ec2d0de345cd9903659a638 Mon Sep 17 00:00:00 2001 From: Sam Wilson <57262657+SamWilsn@users.noreply.github.com> Date: Mon, 30 Jun 2025 15:31:27 -0400 Subject: [PATCH 22/23] Update erc-7895.md --- ERCS/erc-7895.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ERCS/erc-7895.md b/ERCS/erc-7895.md index d14c739a760..4d9fad51b0d 100644 --- a/ERCS/erc-7895.md +++ b/ERCS/erc-7895.md @@ -210,7 +210,7 @@ const response = { ### Naming -Initial intent was to leverage existing RPCs, like `wallet_connect` (e.g. ERC-7846 with additional capabilities to add support for these new features, but these methods ultimately lacked flexibility. Then there were custom namespaced RPCs but this resulted with more fragmentation within the community. +Initial intent was to leverage existing RPCs, like `wallet_connect` (e.g. with additional capabilities to add support for these new features, but these methods ultimately lacked flexibility. Then there were custom namespaced RPCs but this resulted with more fragmentation within the community. Method names explored `wallet_linkAccount`, `wallet_importAddress`, `wallet_addAddress`, or something else. Multiple RPCs were explored as well, separating create and tracking as two separate RPCs. To consolidate on a single RPC `wallet_addSubAccount` was selected. This method is more inclusive for EOA use cases. From c6f914febcc50dc9118b8489f89093cba9090f40 Mon Sep 17 00:00:00 2001 From: Sam Wilson <57262657+SamWilsn@users.noreply.github.com> Date: Mon, 30 Jun 2025 15:52:04 -0400 Subject: [PATCH 23/23] Update erc-7895.md --- ERCS/erc-7895.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ERCS/erc-7895.md b/ERCS/erc-7895.md index 4d9fad51b0d..19670bbd963 100644 --- a/ERCS/erc-7895.md +++ b/ERCS/erc-7895.md @@ -148,7 +148,7 @@ type Parameters = { #### `wallet_connect` -This ERC conforms to which includes [ERC-5792](./erc-5792.md) capabilities specification and introduces two new capabilities for `wallet_connect`. +This ERC conforms to which includes [ERC-5792](./eip-5792.md) capabilities specification and introduces two new capabilities for `wallet_connect`. ##### `addSubAccount` @@ -178,7 +178,7 @@ type Response = { #### `wallet_getCapabilities` -This ERC conforms with `wallet_getCapabilities` [ERC-5792](./erc-5792.md). The response will accommodate addSubAccount support for wallets that support it. +This ERC conforms with `wallet_getCapabilities` [ERC-5792](./eip-5792.md). The response will accommodate addSubAccount support for wallets that support it. ```typescript type Response = { @@ -216,7 +216,7 @@ Method names explored `wallet_linkAccount`, `wallet_importAddress`, `wallet_add ## Backwards Compatibility -This standard builds on existing JSON-RPC methods and complements [ERC-5792](./erc-5792.md) for future extensibility. Wallets can continue supporting legacy methods. +This standard builds on existing JSON-RPC methods and complements [ERC-5792](./eip-5792.md) for future extensibility. Wallets can continue supporting legacy methods. ## Security Considerations