Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

MagicAuthConnector how to change network #77

Open
nacr opened this issue May 11, 2023 · 4 comments
Open

MagicAuthConnector how to change network #77

nacr opened this issue May 11, 2023 · 4 comments

Comments

@nacr
Copy link

nacr commented May 11, 2023

  • I'm submitting a question about how to use this project

Is how can I use a different network when using MagicAuthConnector?

Thank you.

@EmanueleBordoni
Copy link

You need to set the Chain on MagicAuthConnector initialization:

import { polygon, polygonMumbai } from "wagmi/chains";

const magicAuth = new MagicAuthConnector({
  chains: [polygon, polygonMumbai],
  options: {
    apiKey: "pk_live_", //required
    oauthOptions: {
      providers: [
        "google",
      ],
    },
  },
});

@hickscorp
Copy link

I'd like to revive this question - we're doing exactly that, but we cannot figure out how to have the user change the chain.
With Metamask, there's UI for the user to do so - what would be the corresponding flow with Magic?

@nacr
Copy link
Author

nacr commented May 18, 2023

@EmanueleBordoni sorry but that solution seems not to work.

This is my current solution.

new MagicAuthConnector({
  options: {
    apiKey: 'pk_live_', //required
    magicSdkConfiguration: {
      network: {
        rpcUrl: 'https://matic-mumbai.chainstacklabs.com', // your ethereum, polygon, or optimism mainnet/testnet rpc URL
        chainId: 80001,
      },
    }
    //...Other options
},

my problem now is changing network.

@cuervoshi
Copy link

I have some problem.
switchNetwork not work. Require reinitialize.

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

No branches or pull requests

4 participants