Skip to content

Commit 5fa6bd2

Browse files
Merge d91b259 into 4f1cbd0
2 parents 4f1cbd0 + d91b259 commit 5fa6bd2

File tree

1 file changed

+235
-0
lines changed

1 file changed

+235
-0
lines changed

ERCS/erc-7846.md

Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
---
2+
eip: 7846
3+
title: Wallet Connection API
4+
description: Adds JSON-RPC method for requesting wallet connection with modular capabilities.
5+
author: Conner Swenberg (@ilikesymmetry), Jake Moxey (@jxom), Lukas Rosario (@lukasrosario).
6+
discussions-to: https://ethereum-magicians.org/t/erc-7846-wallet-connection-api/22245
7+
status: Draft
8+
type: Standards Track
9+
category: ERC
10+
created: 2024-12-15
11+
---
12+
13+
## Abstract
14+
15+
This ERC introduces a new wallet connection JSON-RPC method focused on extensibility, `wallet_connect`. 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.
16+
17+
## Motivation
18+
19+
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.
20+
21+
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).
22+
23+
## Specification
24+
25+
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.
26+
27+
### JSON-RPC Methods
28+
29+
#### `wallet_connect`
30+
31+
Requests to connect account(s) with optional capabilities.
32+
33+
##### Request
34+
35+
```ts
36+
type Request = {
37+
method: 'wallet_connect',
38+
params: [{
39+
// JSON-RPC method version.
40+
version: string;
41+
// Optional capabilities to request (e.g. Sign In With Ethereum).
42+
capabilities?: Record<string, unknown>;
43+
}]
44+
}
45+
```
46+
47+
##### Response
48+
49+
List of connected accounts with their associated capabilities.
50+
51+
```ts
52+
type Response = {
53+
accounts: {
54+
// Address of the connected account.
55+
address: `0x${string}`;
56+
// Capabilities granted that is associated with this account.
57+
capabilities: Record<string, unknown>;
58+
}[]
59+
}
60+
```
61+
62+
##### Example
63+
64+
```ts
65+
const response = await provider.request({
66+
method: 'wallet_connect',
67+
params: [{
68+
version: '1',
69+
capabilities: {
70+
signInWithEthereum: {
71+
nonce: '12345678',
72+
chainId: '0x1'
73+
}
74+
}
75+
}]
76+
})
77+
/**
78+
* {
79+
* accounts: [
80+
* {
81+
* address: '0x...',
82+
* capabilities: {
83+
* signInWithEthereum: {
84+
* message: 'app.com wants you to sign in with your Ethereum account:\n0x...',
85+
* signature: '0x...'
86+
* }
87+
* }
88+
* }
89+
* ]
90+
* }
91+
*/
92+
```
93+
94+
#### `wallet_disconnect`
95+
96+
Disconnects connected account(s).
97+
98+
- 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`.
99+
100+
##### Request
101+
102+
```ts
103+
type Request = {
104+
method: 'wallet_disconnect'
105+
}
106+
```
107+
108+
##### Example
109+
110+
```ts
111+
await provider.request({
112+
method: 'wallet_disconnect',
113+
})
114+
```
115+
116+
### Capabilities
117+
118+
#### `signInWithEthereum`
119+
120+
Adds support for offchain authentication using [ERC-4361](./eip-4361.md).
121+
122+
##### Parameters
123+
124+
Same as ERC-4361 specification with minor modifications:
125+
* The casing of multi-word fields has been adjusted to camelCase instead of kebab-case. Resources are an array field.
126+
* The account address returned by `wallet_connect` MUST match the address inferred in the Sign-In with Ethereum (SIWE) message.
127+
* `version` is optional and defaults to an accepted version defined in ERC-4361 if not provided.
128+
* `domain` is optional and defaults to the domain of the requesting app if not provided.
129+
* `uri` is optional and defaults to the uri of the requesting app if not provided.
130+
* `issuedAt` is optional and defaults to the current time if not provided.
131+
132+
The wallet MUST return a ERC-4361-formatted message that exactly matches the requested parameters and a signature over the EIP-191 `personal_sign` hash of the message. The app SHOULD also verify that the two match for security.
133+
134+
```ts
135+
type Parameters = {
136+
signInWithEthereum: {
137+
nonce: string;
138+
chainId: string; // EIP-155 hex-encoded
139+
version?: string;
140+
scheme?: string;
141+
domain?: string;
142+
uri?: string;
143+
statement?: string;
144+
issuedAt?: string;
145+
expirationTime?: string;
146+
notBefore?: string;
147+
requestId?: string;
148+
resources?: string[];
149+
}
150+
}
151+
```
152+
153+
##### Response
154+
155+
Formatted SIWE message and signature.
156+
157+
```ts
158+
type Response = {
159+
signInWithEthereum: {
160+
// Formatted SIWE message.
161+
message: string;
162+
// Signature over the EIP-191 personal_sign hash of the message.
163+
signature: `0x${string}`;
164+
}
165+
}
166+
```
167+
168+
#### Example
169+
170+
```ts
171+
const result = await provider.request({
172+
method: 'wallet_connect',
173+
params: [{
174+
version: '1',
175+
capabilities: {
176+
signInWithEthereum: {
177+
nonce: '12345678',
178+
chainId: '0x1',
179+
version: '1',
180+
domain: 'app.com',
181+
uri: 'https://app.com/connect',
182+
issuedAt: '2024-12-35T04:20:00Z',
183+
expirationTime: '2024-12-35T06:09:00Z'
184+
}
185+
}
186+
}]
187+
})
188+
/**
189+
* {
190+
* accounts: [
191+
* {
192+
* address: '0x...',
193+
* capabilities: {
194+
* signInWithEthereum: {
195+
* message: 'app.com wants you to sign in with your Ethereum account:\n0x...',
196+
* signature: '0x...'
197+
* }
198+
* }
199+
* }
200+
* ]
201+
* }
202+
*/
203+
```
204+
205+
## Rationale
206+
207+
### Multiple Accounts
208+
209+
Returning multiple accounts allows greater generality for apps that wish to interact in more complex ways with users. This also improves our backwards compatibility with `eth_requestAccounts`. In practice, we expect most apps only interact with the first account in the array.
210+
211+
### Capability Results
212+
213+
Returning capability results alongside the connection unlocks many valuable use cases such as authentication, user metadata sharing, and permissions granted to the app.
214+
215+
### Initial Authentication Capability
216+
217+
To ensure immediate value, this proposal includes a capability that combines wallet connection with authentication using the widely adopted [Sign In With Ethereum (ERC-4361)](https://eips.ethereum.org/EIPS/eip-4361) standard. This optional capability simplifies the onboarding process for apps and users by combining two steps — connection and authentication — into a single interaction. Apps that prefer alternative authentication flows can implement their own capabilities without being constrained by this design.
218+
219+
By unifying connection and authentication into one step, apps can reduce friction, improve the user experience, and minimize redundant interactions.
220+
221+
## Backwards Compatibility
222+
223+
This standard builds on existing JSON-RPC methods and complements ERC-5792 for future extensibility. Wallets can continue supporting legacy methods.
224+
225+
## Security Considerations
226+
227+
Applies [ERC-4361 security principles](https://eips.ethereum.org/EIPS/eip-4361#security-considerations). As more capabilities are added, care must be taken to avoid unpredictable interactions.
228+
229+
## Privacy Considerations
230+
231+
Wallet addresses and any shared capabilities must be handled securely to avoid data leaks or man-in-the-middle attacks.
232+
233+
## Copyright
234+
235+
Copyright and related rights waived via [CC0](../LICENSE.md).

0 commit comments

Comments
 (0)