MagicAuthConnector how to change network
nacr opened this issue · 4 comments
nacr commented
- 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 commented
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 commented
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 commented
@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 commented
I have some problem.
switchNetwork not work. Require reinitialize.