How to change network to BSC in Magic Link Authentication?

Sup guys?!
I’m using Magic Link to authenticate. But how do I change the network to BSC(mainnet)? Is it the same way like the other login methods by specifying network: "bsc" or something else… Because other login methods have chain: parameter and Magic Link has network: parameter! So I wonder asigning "bsc" to network: will work or not! Need some clarification here please!

1 Like

here you must specify the netwrok ID. for bsc this is 56. consider below an example given in th docs which is connecting to opimism

const customNodeOptions = {
  rpcUrl: '',
  chainId: 69

// Setting network to Optimism Testnet
export const magicOptimism = new Magic(process.env.REACT_APP_MAGIC_PUBLISHABLE_KEY, { network: customNodeOptions });

although i believe the chainID alone should be enough also. but yes to awnser your question you need to use the chain ID as the network and not a string of the chain name as you have


Thanks it worked for BSC!:innocent:


I’m also using Magic Link to authenticate users, through the Moralis integration. It works great! Here’s my code, with the network specified as “rinkeby” plus error handling. It works fine using the Moralis.authenticate with options set.

const magicWalletHandler = async () => {
    await authenticate({
      provider: "magicLink",
      apiKey: "pk_XXXXXXXXXXXXXXXX",
      network: "rinkeby",
      .then(function (user) {
        console.log("logged in user:", user);
      .catch(function (error) {

The open question I have is about the user changing networks. If the user authenticates through Moralis.authenticate with the magicLink provider, and then the user changes networks, do they have to login all over again with Magic Link?

If there’s no option to change the chain within the Magic interface then you’ll have to re-authenticate.

I reached out to Magic to find out. I’m also reaching out to Web3Auth because their wallet has the ability to change chains, but I still can’t find it in the documentation for custom auth.

It’s hard enough to get novice users to try the product, so I don’t want to overwhelm them at onboarding by making them choose a chain!

What chain are the contracts deployed on that users will be interacting with in your app? That probably should be your default chain for Magic.

Magic DOES support changing chains without having to reauthenticate, and the public address is the same when you change chains. They provide a demo here:

The question is wether it is possible to pass the full node options to Magic through the Moralis integration, like when you work with Magic directly:

import { Magic } from 'magic-sdk';
import Web3 from 'web3';

 * Configure Polygon Connection
const polygonNodeOptions = {
  rpcUrl: '',
  chainId: 80001,

export const magicMatic = new Magic(
  { network: polygonNodeOptions }
); = 'matic';

export const maticWeb3 = new Web3(magicMatic.rpcProvider);

 * Configure Ropsten Connection
const ropstenNodeOptions = {
  rpcUrl: process.env.REACT_APP_ROPSTEN_RPC,
  chainId: 3,

export const magicEthereum = new Magic(
  { network: ropstenNodeOptions }
); = 'ethereum';

export const ethWeb3 = new Web3(magicEthereum.rpcProvider);
1 Like

The question is wether it is possible to pass the full node options to Magic through the Moralis integration, like when you work with Magic directly:

You can look at the Magic connector to see how this could be integrated.

Yeah currently no switchNetwork in the magic link Moralis integration. Alternatively, customization with Moralis is possible for any EIP1193 provider. Since MagicLink already has it’s connector in our SDK, I believe you can simply extend it to create a new MagicLink custom connector that includes a switchNetwork functionality within the MagicLink connector class :raised_hands: