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. Specified by EIP-3085.
Parameters
Chain(object)Object containing information about the chain to add.
Returns
This method returns null if the chain is added.
Errors
| Code | Description |
|---|---|
-32602 | Expected null or array with at least one valid string HTTPS URL 'blockExplorerUrl'. Received: ${blockExplorerUrls} |
-32602 | Expected 0x-prefixed, unpadded, non-zero hexadecimal string 'chainId'. Received: ${chainId} |
-32602 | Invalid chain ID "${_chainId}": numerical value greater than max safe value. Received: ${chainId} |
-32602 | May not specify default MetaMask chain. |
-32602 | Expected 2-6 character string 'nativeCurrency.symbol'. Received: ${ticker} |
-32602 | nativeCurrency.symbol does not match currency symbol for a network the user already has added with the same chainId. Received: ${ticker} |
await provider.request({
method: "wallet_addEthereumChain",
params: [
{
"chainId": "0x64",
"chainName": "Gnosis",
"rpcUrls": [
"https://rpc.gnosischain.com"
],
"iconUrls": [
"https://xdaichain.com/fake/example/url/xdai.svg",
"https://xdaichain.com/fake/example/url/xdai.png"
],
"nativeCurrency": {
"name": "XDAI",
"symbol": "XDAI",
"decimals": 18
},
"blockExplorerUrls": [
"https://blockscout.com/poa/xdai/"
]
}
]
});
{
"id": 1,
"jsonrpc": "2.0",
"result": null
}