EIPs Explained

EIP-3014 · Stagnant · Interface · 2020-09-30

EIP-3014: eth_symbol JSON-RPC method

Proposed an eth_symbol JSON-RPC method that returns the native coin's ticker (e.g. "ETH"), so multi-chain wallets don't need users to type it in.

What problem does it solve?

A wallet that connects to many EVM networks needs some basic facts about each one. The chain ID can already be read from the node with eth_chainId (EIP-695), but the symbol of the native coin cannot. Users had to look it up in community lists and enter it by hand.

ERC-3014 proposes letting the node report it directly, much as an ERC-20 token reports its own symbol().

How it works

A new read-only method:

  • Method: eth_symbol
  • Params: none
  • Returns: a string with the native coin's symbol, e.g. "ETH" on mainnet

That's the entire specification. The authors considered the name eth_nativeCurrencySymbol but chose the shorter name because the eth_ namespace and single return value make the meaning clear.

Sample code

Raw JSON-RPC request and response, as in the spec:

curl -X POST -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"eth_symbol","params":[],"id":1}' \
  "$RPC_URL"
{ "id": 1, "jsonrpc": "2.0", "result": "ETH" }

Calling it from ethers v6, with a fallback because most nodes do not implement it:

import { JsonRpcProvider } from "ethers";

const provider = new JsonRpcProvider(process.env.RPC_URL);

async function nativeSymbol(): Promise<string | undefined> {
  try {
    return await provider.send("eth_symbol", []);
  } catch {
    return undefined; // method not supported: use your own chain list
  }
}

Things to know

  • Status is Stagnant. Major clients do not implement eth_symbol, so do not rely on it.
  • The value is only as trustworthy as the node. A malicious RPC could report a misleading symbol and trick a user about which coin they are handling.
  • In practice, wallets learn the native currency from their own chain lists or from the nativeCurrency field supplied via wallet_addEthereumChain (EIP-3085).

#json-rpc #wallet #interface #multichain

Details

Authors
Peter Grassberger (@PeterTheOne)
Status
Stagnant
Type
Standards Track / Interface
Created
2020-09-30

Machine-readable: Markdown · JSON