[Archive] Want to switch to another chain after login

:classical_building: Archived Content from Web3Auth Community

This topic was originally posted by githubdiscussions on 12/12/2022.
This content has been migrated from our previous community forum to preserve valuable discussions.


After I log-in on ethereum, I want to switch to another chain (e.g. AVAX) while logged-in.

In other words,

  • configure metamask adapter with ethereum
  • log in using metamask adapter on ethereum
  • now, I want to request chain switch on metamask


Originally posted by: softcheetah

Check the discussion at: https://github.com/orgs/Web3Auth/discussions/1057

You could refer this example code
https://github.com/Web3Auth/web3auth-wagmi-connector/blob/master/src/lib/connector.ts#L237

      await this.provider.request({
        method: "wallet_switchEthereumChain",
        params: [
          {
            chainId: `0x${chain.id.toString(16)}`,
          },
        ],
      });



Originally posted by: ieow