EIPs Explained

ERC-7846 · Draft · ERC · 2024-12-15

ERC-7846: Wallet Connection API

Adds a wallet_connect JSON-RPC method that connects accounts and returns extra capabilities, such as a Sign-In with Ethereum signature, in one wallet interaction.

What problem does it solve?

Logging into a dapp with a wallet usually takes two prompts: eth_requestAccounts to connect, then personal_sign to sign a Sign-In with Ethereum message. Neither method is extensible, so there is no clean way to ask for more during connection (authentication, profile data, permissions).

ERC-7846 introduces wallet_connect, a connection method built around capabilities, the same modular idea used by ERC-5792. Connecting and authenticating become a single interaction.

How it works

wallet_connect takes one object:

  • version: the method version (e.g. "1").
  • capabilities (optional): a map of capability name to parameters.

It returns accounts, an array of { address, capabilities }, where each account carries the results of the capabilities granted for it. Returning several accounts keeps it compatible with eth_requestAccounts; most apps will use the first.

wallet_disconnect asks the wallet to drop the connection. The wallet should revoke access to the accounts and to any capabilities granted through wallet_connect.

The ERC defines one capability up front, signInWithEthereum, based on ERC-4361:

  • Request fields are the SIWE fields in camelCase: nonce and chainId are required; domain, uri, issuedAt, version and others are optional and default sensibly.
  • The wallet returns the formatted SIWE message and a signature over its EIP-191 personal_sign hash.
  • The address in the message must match the connected account, and the app should check that the message matches what it asked for.

Sample code

Connect and sign in at once through an EIP-1193 provider, then verify (ethers v6):

import { verifyMessage } from "ethers";

const nonce = crypto.randomUUID().replace(/-/g, ""); // server-issued in practice

const { accounts } = await window.ethereum.request({
  method: "wallet_connect",
  params: [{
    version: "1",
    capabilities: {
      signInWithEthereum: { nonce, chainId: "0x1" },
    },
  }],
});

const [{ address, capabilities }] = accounts;
const { message, signature } = capabilities.signInWithEthereum;

// Check on your backend: signer, nonce, domain and expiry
const signer = verifyMessage(message, signature);
if (signer.toLowerCase() !== address.toLowerCase()) throw new Error("bad SIWE signature");
if (!message.includes(`Nonce: ${nonce}`)) throw new Error("nonce mismatch");

Things to know

  • Status: Draft. Wallet support varies, so fall back to eth_requestAccounts plus personal_sign when the method is not available.
  • verifyMessage only works for EOAs. Smart-contract wallets need ERC-1271 verification, ideally via a full SIWE library.
  • The usual SIWE rules still apply: issue nonces server-side, check domain, URI and expiry, and never accept a message you did not request.
  • New capabilities can be added over time; the spec warns that combining them needs care to avoid unexpected interactions.

#wallet #json-rpc #siwe #connection #ux

Details

Authors
Conner Swenberg (@ilikesymmetry), Jake Moxey (@jxom), Lukas Rosario (@lukasrosario)
Status
Draft
Type
Standards Track / ERC
Created
2024-12-15

Machine-readable: Markdown · JSON