walletconnect-dart-sdk icon indicating copy to clipboard operation
walletconnect-dart-sdk copied to clipboard

I just want to know how to switch the network in MetaMask mobile using code

Open Asadu43 opened this issue 1 year ago • 3 comments

I just want to know how to switch the network in MetaMask mobile using code

Asadu43 avatar Jun 09 '23 04:06 Asadu43

You can try "wallet_switchEthereumChain" or "wallet_addEthereumChain"

wufd avatar Jun 12 '23 11:06 wufd

You can try "wallet_switchEthereumChain" or "wallet_addEthereumChain"

Can you please Give me any example how can i use this?

Asadu43 avatar Jun 20 '23 10:06 Asadu43

await connector.sendCustomRequest(
        method: 'wallet_switchEthereumChain',
        params: [
          {'chainId': '0x${chainId.toRadixString(16)}'}
        ],
      )

or

await connector.sendCustomRequest(
        method: 'wallet_addEthereumChain',
        params: [
          {
            'chainId': '0x${chainId.toRadixString(16)}',
            'chainName': "xxx",
            'nativeCurrency': {
                      "name": "xxx",
                      "symbol": "xxx",
                      "decimals": xxx
            },
            'rpcUrls': [url,xxx],
            'blockExplorerUrls': [url,xxx]
          }
        ],
      )

chain_info: https://chainid.network/chains.json

wufd avatar Jun 21 '23 03:06 wufd