if I change networks within Torus wallet, it displays Mumbai, but when I try to initiate transaction, getting same error as before, meaning I don’t think network actually changes.
Here’s how I’ve it configured:
import { CHAIN_NAMESPACES, CustomChainConfig } from "@web3auth/base";
export const CHAIN_CONFIG = {
mainnet: {
displayName: "Ethereum Mainnet",
chainNamespace: CHAIN_NAMESPACES.EIP155,
chainId: "0x1",
rpcTarget: `https://rpc.ankr.com/eth`,
blockExplorer: "https://etherscan.io/",
ticker: "ETH",
tickerName: "Ethereum",
} as CustomChainConfig,
mumbai: {
chainNamespace: CHAIN_NAMESPACES.EIP155,
chainId: "0x13881", // hex of 80001, polygon testnet
rpcTarget: "https://rpc.ankr.com/polygon_mumbai",
displayName: "Polygon Mumbai Testnet",
blockExplorer: "https://mumbai.polygonscan.com/",
ticker: "MATIC",
tickerName: "Matic",
} as CustomChainConfig,
celo: {
chainNamespace: CHAIN_NAMESPACES.EIP155,
chainId: "0xa4ec", // hex of 42220, Celo mainnet
rpcTarget: "https://celo-mainnet.infura.io/v3/c$$$1151672f049e6a",
displayName: "Celo Mainnet",
blockExplorer: "https://explorer.celo.org",
ticker: "CELO",
tickerName: "CELO",
} as CustomChainConfig,
polygon: {
chainNamespace: CHAIN_NAMESPACES.EIP155,
rpcTarget: "https://polygon-rpc.com",
blockExplorer: "https://polygonscan.com/",
chainId: "0x89",
displayName: "Polygon Mainnet",
ticker: "matic",
tickerName: "Matic",
} as CustomChainConfig,
tezos: {
chainNamespace: CHAIN_NAMESPACES.OTHER,
displayName: "Tezos Ithacanet",
} as CustomChainConfig,
} as const;
export type CHAIN_CONFIG_TYPE = keyof typeof CHAIN_CONFIG;
async function init() {
try {
const currentChainConfig = CHAIN_CONFIG[chain];
setIsLoading(true);
const clientId = process.env.NEXT_PUBLIC_WEB3_CLIENT_ID || "defaultClientId";
const web3AuthInstance = new Web3Auth({
chainConfig: currentChainConfig,
clientId,
uiConfig: {
appName: "Gream",
appLogo: "https://web3auth.io/images/w3a-L-Favicon-1.svg",
theme: "light",
loginMethodsOrder: ["twitter", "google"],
defaultLanguage: "en",
primaryButton: "socialLogin",
},
enableLogging: true,
web3AuthNetwork: 'mainnet',
});
/*const adapter = new OpenloginAdapter({
adapterSettings: {
network: web3AuthNetwork,
clientId,
loginConfig: {
facebook: {
name: "Custom Auth Login",
verifier: "facebook", // Please create a verifier on the developer dashboard and pass the name here
typeOfLogin: "facebook", // Pass on the login provider of the verifier you've created
showOnModal: false,
},
},
},
});
web3AuthInstance.configureAdapter(adapter);*/
const plugin = new TorusWalletConnectorPlugin({
torusWalletOpts: {},
walletInitOptions: {
whiteLabel: {
theme: { isDark: true, colors: { primary: "#00a8ff" } },
logoDark: "https://web3auth.io/images/w3a-L-Favicon-1.svg",
logoLight: "https://web3auth.io/images/w3a-D-Favicon-1.svg",
},
useWalletConnect: true,
enableLogging: true,
},
});
web3AuthInstance.addPlugin(plugin);
subscribeAuthEvents(web3AuthInstance);
setWeb3Auth(web3AuthInstance);
await web3AuthInstance.initModal({
modalConfig: modalConfig,
});
} catch (error) {
console.error(error);
} finally {
setIsLoading(false);
}
}