Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Asadu43 opened this issue Jun 9, 2023 · 3 comments

Comments

@Asadu43
Copy link

Asadu43 commented Jun 9, 2023

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

@wufd
Copy link

wufd commented Jun 12, 2023

You can try "wallet_switchEthereumChain" or "wallet_addEthereumChain"

@Asadu43
Copy link
Author

Asadu43 commented Jun 20, 2023

You can try "wallet_switchEthereumChain" or "wallet_addEthereumChain"

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

@wufd
Copy link

wufd commented Jun 21, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants