ERC-5094 URL format for network switching (URL Format for Ethereum Network Switching)

Stagnant · Accounts & wallets · created 2022-05-13

A standard that lets a wallet add a new network through a single URL containing the chain ID, RPC address, network name, and so on.

Why it is needed

An Ethereum wallet can receive a transaction URL such as EIP-681 to process a payment or transfer, but the operation fails if the wallet has not yet registered the chain the URL points to as a network. A chain_id alone does not convey the information actually needed to connect, such as the RPC address, network name, token symbol, decimals, or explorer address. As a result, users wanting to use a chain other than mainnet had to manually configure the wallet by entering the RPC URL and chain information themselves, which was especially cumbersome on mobile wallets. With no standard way to automate the network-adding process via deep link or QR code, each service had to build its own separate guidance screens or manual setup guides.

In depth

Basic URL structure

A network-switching URL includes ethereum in its scheme and is structured as ethereum:network-add@<chain_id>?<parameters>. The erc831_part is 'ethereum:network-', followed by 'add', '@', and the decimal chain ID (chain_id). This is followed by an optional '/' and then '?' leading into the parameter list. Parameters are key=value pairs joined by '&'.

Required parameters: chain_id, chain_name, rpc_url

chain_id is the required decimal chain identifier of the network to be added. chain_name specifies the name of the network to be added and is required. rpc_url is an array of RPC endpoints; at least one must be present, and if there are multiple, the rpc_url parameter is repeated for each (e.g. rpc_url=A&rpc_url=B).

Optional parameters: name, symbol, decimals, explorer_url, icon_url

If provided, name and symbol should be human-readable strings representing the native token (SHOULD). If provided, decimals must be a non-negative integer representing the native token's decimal precision (MUST). If provided, explorer_url must specify one or more URLs pointing to that chain's block explorer website (MUST). If provided, icon_url must specify one or more URLs pointing to an appropriately sized image that visually identifies the chain (MUST).

String encoding rules

A value is either a STRING or a number. A STRING is a URL-encoded Unicode string of arbitrary length, and delimiters and percent signs (%) must be encoded in hexadecimal prefixed with %. If the key is decimals, the value must be a number.

Relationship to EIP-831 and EIP-681

This URL follows EIP-831, where PREFIX is 'network' and PAYLOAD is a combination of 'add' with an EIP-681-style chain_id and parameters. PREFIX was set to 'network' so that it can be extended in the future with variants following the 'network-x' pattern. Allowing multiple values for rpc_url and explorer_url is also designed with an eye toward avoiding duplication with the TYPE parsing mentioned in EIP-681.

Example

A URL that adds a network with RPC https://rpc-polygon.com and https://rpc-mainnet.matic.network, name Polygon Mainnet, token Matic, symbol MATIC, 18 decimals, explorer https://polygonscan.com/, and chain ID 137 takes the form ethereum:network-add@137/?chain_name=Polygon%20Mainnet&rpc_url=https%3A%2F%2Frpc-polygon.com&rpc_url=https%3A%2F%2Frpc-mainnet.matic.network&name=Matic&symbol=MATIC&decimals=18&explorer_url=https%3A%2F%2Fpolygonscan.com.

Standard status

This proposal is currently Stagnant, a draft that has not been finalized and is no longer being actively discussed.

Things to watch out for

Original ERC · ← ERCs