Can't store ethersProvider to recoil in React

I connected the web3auth using custom login
await web3auth.connectTo(WALLET_ADAPTERS.OPENLOGIN, ... )

After that, I got the ethers provider and tried to store to recoil, but showed error:
ethersProvider = new ethers.providers.Web3Provider(web3auth.provider); setEthersProvider(ethersProvider);
image



Originally posted by: polartar

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

Hey @talentdev2020

Are you using something similar code?

https://YOUR-DOMAIN", // if using Auth0, Cognito or Firebase.
verifierIdField: "sub",
},
});

const provider = new ethers.providers.Web3Provider(web3auth.provider);“>

import { Web3AuthCore } from @web3auth/core";
import { OpenloginAdapter } from @web3auth/openlogin-adapter”;
import { WALLET_ADAPTERS, CHAIN_NAMESPACES } from @web3auth/base”;
import { ethers } from “ethers”;

const web3auth = new Web3AuthCore({
clientId: “YOUR_CLIENT_ID”, // get it from Web3Auth Dashboard
chainConfig: {
chainNamespace: CHAIN_NAMESPACES.EIP155,
chainId: “0x3”, // ropsten, hex of 3
},
});

const openloginAdapter = new OpenloginAdapter({
adapterSettings: {
clientId: “YOUR-WEB3AUTH-CLIENT-ID”,
network: “testnet”,
uxMode: “popup”,
loginConfig: {
jwt: {
name: “Name of your choice”,
verifier: “YOUR-VERIFIER-NAME-ON-WEB3AUTH-DASHBOARD”,
typeOfLogin: “jwt”,
clientId: “YOUR-CLIENTID-FROM-SOCIAL-PROVIDER”,
},
},
},
});

web3auth.configureAdapter(openloginAdapter);

await web3auth.init();

// Login
await web3auth.connectTo(WALLET_ADAPTERS.OPENLOGIN, {
loginProvider: “jwt”,
extraLoginOptions: {
domain: https://YOUR-DOMAIN, // if using Auth0, Cognito or Firebase.
verifierIdField: “sub”,
},
});

const provider = new ethers.providers.Web3Provider(web3auth.provider);

Also, try looking at our guides to see if anything matches your requirement or not.



Originally posted by: shahbaz17