wallet_addethereumchain(添加网络)
var res = await window.ethereum.request({
"method": "wallet_addEthereumChain",
"params": [{
"chainId": "0x64", // 链 ID (必填)
"chainName": "Gnosis", // 链名(必填)
"rpcUrls": [ // RPC(必填)
"https://rpc.ankr.com/gnosis"
],
"iconUrls": [ // 图标Url(可选)
"https://xdaichain.com/fake/example/url/xdai.svg",
"https://xdaichain.com/fake/example/url/xdai.png"
],
"nativeCurrency": {
"name": "xDAI", // 货币符号(必填)
"symbol": "xDAI", // 货币符号(必填)
"decimals": 18 // 精度(必填)
},
"blockExplorerUrls": [ // 区块浏览器 URL(必填)
"https://blockscout.com/poa/xdai/"
]
}]
});