EIPs Explained

ERC-7871 · Draft · ERC · 2024-01-29

ERC-7871: Wallet Signing API

Proposes a single wallet_sign JSON-RPC method that covers every EIP-191 signature type (personal_sign, EIP-712 typed data, validator data) with EIP-5792-style capabilities.

What problem does it solve?

Today a dapp asking for an off-chain signature has to choose between several RPC methods: personal_sign, eth_sign, eth_signTypedData_v4 and variants. Each wallet and library supports a slightly different set, and every new signing format would need yet another method.

ERC-7871 consolidates them into one method, wallet_sign. The type of data being signed is a parameter rather than a method name, so future EIP-191 signed_data versions can be added without new RPC methods. It also borrows the capabilities mechanism from EIP-5792, so wallets can advertise and accept extra signing features.

How it works

wallet_sign takes:

  • version: version of the wallet_sign interface itself (e.g. "1.0").
  • address (optional): if given, the wallet must sign with exactly that address.
  • request.type: the one-byte EIP-191 version.
  • request.data: the payload for that version.
  • capabilities (optional): EIP-5792-style feature flags, discoverable via wallet_getCapabilities.

Request shapes defined for the existing EIP-191 versions:

type Meaning data
0x00 Data with intended validator { validator, data }
0x01 EIP-712 typed data the full typed-data object
0x45 Personal sign { message } (UTF-8 string)

The result is { signature, capabilities? }. New signed_data versions are expected to define their request shapes in their own ERCs.

Sample code

Calling wallet_sign through an EIP-1193 provider (TypeScript):

const provider = (window as any).ethereum;

// Personal-sign style message
const { signature } = await provider.request({
  method: "wallet_sign",
  params: [{
    version: "1.0",
    request: { type: "0x45", data: { message: "Hello world" } },
  }],
});

// EIP-712 typed data from a specific account
const typed = await provider.request({
  method: "wallet_sign",
  params: [{
    version: "1.0",
    address: account,
    request: {
      type: "0x01",
      data: {
        domain: { name: "Example", version: "1", chainId: 1 },
        types: { Mail: [{ name: "contents", type: "string" }] },
        primaryType: "Mail",
        message: { contents: "hi" },
      },
    },
  }],
});

Things to know

  • Status: Draft. The Rationale, Backwards Compatibility and Security Considerations sections are still empty, and the interface may change.
  • Not a replacement you can rely on yet: check wallet support (for example via wallet_getCapabilities) and fall back to personal_sign / eth_signTypedData_v4.
  • The spec does not wrap the params in an array explicitly; the array form above follows the usual JSON-RPC convention and may differ by wallet.
  • Signatures are still standard EIP-191 / EIP-712 signatures; verification on-chain or off-chain is unchanged.

#wallet #json-rpc #signatures #eip-712 #draft

Details

Authors
Lukas Rosario (@lukasrosario), Jake Moxey (@jxom), Cody Crozier (@wcrozier12), Conner Swenberg (@ilikesymmetry)
Status
Draft
Type
Standards Track / ERC
Created
2024-01-29
Requires

Machine-readable: Markdown · JSON