wallet_addEthereumChain

Creates a confirmation asking the user to add the specified chain to the wallet application. The caller must specify a chain ID and some chain metadata. The wallet application may refuse or accept the request. null is returned if the chain is added, and an error otherwise. Introduced by EIP-3085.

Params

interface AddEthereumChainParameters {
  chainId: string; // a 0x-prefixed hexadecimal string
  chainName: string; // A human-readable name for the chain.
  rpcUrls: string[]; // One or more URLs pointing to RPC endpoints that can be used to communicate with the chain. At least one item is required, and only the first item is used.
  nativeCurrency: { // Describes the native currency of the chain using the name, symbol, and decimals fields.
    symbol: string; // A human-readable symbol.
    decimals: number; // A non-negative integer.
    name?: string; // A human-readable name.
  },
  blockExplorerUrls?: string[] // One or more URLs pointing to block explorer sites for the chain
}

Example

Request

await window.NEOLineNeoX.request({
  "method": "wallet_addEthereumChain",
  "params": [
    {
      "chainId": "0x1",
      "chainName": "Ethereum LlamaNodes",
      "rpcUrls": ["https://eth.llamarpc.com"],
      "nativeCurrency": {
        "name": "ETH",
        "symbol": "ETH",
        "decimals": 18
      },
      "blockExplorerUrls": ["https://etherscan.io"]
    }
  ]
});

Result

"null"

最后更新于