EIPs Explained

ERC-7811 · Draft · ERC · 2024-11-07

ERC-7811: Wallet Asset Discovery

Adds a wallet_getAssets JSON-RPC method so a wallet can tell a dapp exactly which assets a user holds across chains, including balances the wallet knows about that the dapp could not easily find onchain.

What problem does it solve?

Dapps usually work out a user's balances by reading chain data themselves: one RPC call per token per chain, and only on the chains they think of checking. They miss assets on other chains or accounts, and may block an action (a swap or payment) the wallet could actually handle, for example by routing funds from another chain.

The wallet already knows the user's portfolio, often including assets that are hard to find onchain. ERC-7811 lets the dapp simply ask the wallet.

How it works

Request wallet_getAssets with:

  • account (required): the address to report on.
  • assetFilter (optional): exact assets per EIP-155 chain ID, as { address, type } (address can be "native"). If present, the wallet returns only these and ignores the other two filters.
  • assetTypeFilter (optional): e.g. ["erc20", "native"].
  • chainFilter (optional): list of hex chain IDs.

Without assetFilter, the wallet should return everything it knows, ideally sorted by estimated value. Dapps are asked to filter as narrowly as possible, to keep the call cheap and fast.

Response: an object keyed by hex chain ID, each holding a list of { address, balance, type, metadata }, with balance as hex. Well-known types define the minimum metadata:

  • native: no metadata required.
  • erc20: name, symbol, decimals.
  • erc721: name, symbol, tokenId, optional tokenURI.

Discovery: wallets supporting ERC-5792 should advertise { "assetDiscovery": { "supported": true } } per chain in wallet_getCapabilities; CAIP-25 wallets list the method in their eip155 session scope.

Sample code

// window.ethereum: an EIP-1193 provider
const [account] = await window.ethereum.request({ method: "eth_requestAccounts" });

const assets = await window.ethereum.request({
  method: "wallet_getAssets",
  params: [{
    account,
    assetTypeFilter: ["native", "erc20"],
    chainFilter: ["0x1", "0xa"],          // Ethereum mainnet, OP Mainnet
  }],
});

for (const [chainId, list] of Object.entries(assets)) {
  for (const a of list as any[]) {
    console.log(chainId, a.type, a.metadata?.symbol ?? "native", BigInt(a.balance));
  }
}

Things to know

  • Status is Draft, and the Rationale and Security Considerations sections are still TODO.
  • The data is the wallet's claim. Do not treat it as proof of funds for anything security-sensitive; verify onchain where that matters.
  • type is a free-form string. The spec's own examples mix "erc20" and "ERC20", so compare types case-insensitively.
  • Not all wallets implement it; check wallet_getCapabilities first and fall back to onchain reads.

#wallet #json-rpc #assets #multichain #dapps

Details

Authors
Luka Isailovic (@lukaisailovic), Konrad Kopp (@kopy-kat), Derek Rein (@arein), Chris Smith (@chris13524)
Status
Draft
Type
Standards Track / ERC
Created
2024-11-07
Requires

Machine-readable: Markdown · JSON