-
Notifications
You must be signed in to change notification settings - Fork 828
Add ERC: Wallet Connection API #779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 16 commits
db3b787
ed25a89
25c662e
a97ac05
21e3bd2
0d97ffe
9053be2
294c5eb
4e4b001
2419fd7
c744ba7
aff00cb
4ce54a0
9ad67aa
b73d125
abd1c9f
713214c
1000612
3e89fa9
d91b259
000b07a
5ac1521
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,233 @@ | ||||||
| --- | ||||||
| eip: 7846 | ||||||
| title: Wallet Connection API | ||||||
| description: Adds JSON-RPC method for requesting wallet connection with modular capabilities. | ||||||
| author: Conner Swenberg (@ilikesymmetry), Jake Moxey (@jxom), Lukas Rosario (@lukasrosario). | ||||||
| discussions-to: https://ethereum-magicians.org/t/erc-7846-wallet-connection-api/22245 | ||||||
| status: Draft | ||||||
| type: Standards Track | ||||||
| category: ERC | ||||||
| created: 2024-12-15 | ||||||
| --- | ||||||
|
|
||||||
| ## Abstract | ||||||
|
|
||||||
| This ERC introduces a new wallet connection JSON-RPC method focused on extensibility. It leverages the modular capabilities approach defined in [ERC-5792](https://eips.ethereum.org/EIPS/eip-5792#wallet_getcapabilities) to streamline connections and authentication into a single interaction. | ||||||
|
||||||
|
|
||||||
| ## Motivation | ||||||
|
|
||||||
| With applications beginning to require support for more sophisticated functionality in wallet connection flows, the need for a unified and extensible wallet connection JSON-RPC method has become more apparent. | ||||||
|
|
||||||
| This is especially evident in the case of attempting to batch connection with authentication, where existing methods like `eth_requestAccounts` and `personal_sign` lack extensibility and require at least two separate user interactions (ie. connect and then sign). | ||||||
|
|
||||||
| ## Specification | ||||||
|
|
||||||
SamWilsn marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| ### JSON-RPC Methods | ||||||
|
|
||||||
| #### `wallet_connect` | ||||||
|
|
||||||
| Requests to connect account(s) with optional capabilities. | ||||||
|
|
||||||
| ##### Request | ||||||
|
|
||||||
| ```ts | ||||||
| type Request = { | ||||||
| method: 'wallet_connect', | ||||||
| params: [{ | ||||||
| // JSON-RPC method version. | ||||||
| version: string; | ||||||
| // Optional capabilities to request (e.g. Sign In With Ethereum). | ||||||
| capabilities?: Record<string, unknown>; | ||||||
| }] | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| ##### Response | ||||||
|
|
||||||
| List of connected accounts with their associated capabilities. | ||||||
|
|
||||||
| ```ts | ||||||
| type Response = { | ||||||
| accounts: { | ||||||
| // Address of the connected account. | ||||||
| address: `0x${string}`; | ||||||
| // Capabilities granted that is associated with this account. | ||||||
| capabilities: Record<string, unknown>; | ||||||
| }[] | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| ##### Example | ||||||
|
|
||||||
| ```ts | ||||||
| const response = await provider.request({ | ||||||
| method: 'wallet_connect', | ||||||
| params: [{ | ||||||
| version: '1', | ||||||
| capabilities: { | ||||||
| signInWithEthereum: { | ||||||
| nonce: '12345678', | ||||||
| chainId: '0x1' | ||||||
| } | ||||||
| } | ||||||
| }] | ||||||
| }) | ||||||
| /** | ||||||
| * { | ||||||
| * accounts: [ | ||||||
| * { | ||||||
| * address: '0x...', | ||||||
| * capabilities: { | ||||||
| * signInWithEthereum: { | ||||||
| * message: 'app.com wants you to sign in with your Ethereum account:\n0x...', | ||||||
| * signature: '0x...' | ||||||
| * } | ||||||
| * } | ||||||
| * } | ||||||
| * ] | ||||||
| * } | ||||||
| */ | ||||||
| ``` | ||||||
|
|
||||||
| #### `wallet_disconnect` | ||||||
|
|
||||||
| Disconnects connected account(s). | ||||||
|
|
||||||
| - The wallet SHOULD revoke any capabilities associated with the account(s) that were granted upon connection via `wallet_connect`. | ||||||
|
||||||
| - The wallet SHOULD revoke any capabilities associated with the account(s) that were granted upon connection via `wallet_connect`. | |
| - The wallet SHOULD revoke access to the user account(s) information, as well as to any capabilities associated with them that were granted upon connection via `wallet_connect`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we add optional params in case the user wants to disconnect only specific accounts? or would it be too much.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to use a relative link. Something like:
| Adds support for offchain authentication using [ERC-4361: Sign-In with Ethereum](https://eips.ethereum.org/EIPS/eip-4361). | |
| Adds support for offchain authentication using [ERC-4361](./eip-4361.md). |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should expand the abbreviation the first time it is used:
| * The account address returned by `wallet_connect` MUST match the address inferred in the SIWE message. | |
| * The account address returned by `wallet_connect` MUST match the address inferred in the Sign-In with Ethereum (SIWE) message. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a method to request an accounts switch? To change the targeted account.
In such case should the wallet emit accountsChanged with the order of the accounts array altered?
Also, what if the user is connected with account A but now also wants the connect with B such that A and B are both connected? This has been something pretty much requested from dapp devs and we are using a workaround that only works with MetaMask AFAIK.
Maybe we should add specifications for wallets around this behavior, "wallet_connect" could be called by the dapp more than once to update the state of the connected accounts.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the exact waiver from the template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know there isn't a ton of room in the title (44 characters IIRC), but it would be nice if you could cram a bit more detail in here to help disambiguate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would prefer to keep it as-is to be consistent with 5792 (Wallet Call API)
But if you feel strongly that we should disambiguate further then I'd suggest "Wallet Connection API with Capabilities"