3

sushi交易界面点击对应的网络,metamask会弹出切换网络的弹窗,这是如何实现的? | 登...

 3 years ago
source link: https://learnblockchain.cn/question/2487
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

最佳答案 2天前

有的,这个文章有介绍: EIP-3085: 自定义钱包网络,用二层网络更方便

例如添加一个Fantom网络方法如下:

addChain() {
      var method = 'wallet_addEthereumChain'
      var params = [
        {
          "chainId": "0xfa",
          "chainName": "Fantom Opera Mainnet",
          "rpcUrls": ["https://rpcapi.fantom.network"],
          "nativeCurrency": {
            "name": "ftm",
            "symbol": "ftm",
            "decimals": 18
          },
          "blockExplorerUrls": ["https://ftmscan.com"]
        }
      ]
      web3.currentProvider.sendAsync({
        method,
        params
      }, function (err, result) {
        if (err) {
          console.log('添加失败')
          return false
        }
      })
    },

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK