EIPs Explained

ERC-5094 · Stagnant · ERC · 2022-05-13

ERC-5094: URL Format for Ethereum Network Switching

Proposed an `ethereum:network-add@<chainId>` URL that carries a chain's RPC endpoints, name and currency, so a QR code or deep link can add a network to a wallet in one step.

What problem does it solve?

EIP-681 payment links and QR codes include a chain ID, but a chain ID alone is not enough to connect to a network: the wallet also needs an RPC endpoint, a name and the native currency. If a mobile wallet has never been configured for that chain, scanning the link simply fails.

EIP-5094 defines a URL that carries the whole network configuration, so a user can add a network by scanning or tapping a link and then use other ethereum: URLs on it.

How it works

It follows the EIP-831 ethereum:<prefix>-<payload> pattern with the prefix network and the action add:

ethereum:network-add@<chain_id>/?<parameters>
Parameter Required Meaning
chain_name yes Human-readable network name
rpc_url yes (1 or more) RPC endpoint; repeat the key for several
name, symbol no Native token name and symbol
decimals no Native token decimals (non-negative integer)
explorer_url no Block explorer URL(s)
icon_url no Chain icon URL(s)

chain_id is decimal. Values are URL-encoded, so https:// becomes https%3A%2F%2F. The network- prefix leaves room for future network-x actions such as switching.

Sample code

The spec's example for an L2 network:

ethereum:network-add@10/?chain_name=Optimistic%20Ethereum&rpc_url=https%3A%2F%2Fmainnet.optimism.io&name=Ethereum&symbol=ETH&decimals=18&explorer_url=https%3A%2F%2Foptimistic.etherscan.io

Building one in TypeScript:

function networkAddUrl(chainId: number, chainName: string, rpcUrls: string[]) {
  const q = new URLSearchParams({ chain_name: chainName });
  rpcUrls.forEach((u) => q.append("rpc_url", u));
  return `ethereum:network-add@${chainId}/?${q.toString().replace(/\+/g, "%20")}`;
}

Things to know

  • Status: Stagnant. Wallets did not broadly adopt this URL format.
  • In browser dapps the equivalent action is the wallet_addEthereumChain RPC method from EIP-3085, which many wallets support.
  • A link can carry a malicious RPC URL that lies about balances or censors transactions. Wallets should show the full configuration and users should only add networks from sources they trust.
  • EIP-2400 is a sibling URL format for transaction receipts.

#url #wallets #networks #deep-link #qr

Details

Authors
Luc van Kampen (@lucemans), Jakob Helgesson (@svemat01), Joshua Hendrix (@thejoshuahendrix)
Status
Stagnant
Type
Standards Track / ERC
Created
2022-05-13
Requires

Machine-readable: Markdown · JSON