Hi Peter — thanks for the details, and sorry you’re hitting this. I pulled the important bits from your message and added a few suggestions and requests so the support team can reproduce and help quickly.
Summary of what I see
- SDK: web3auth (no‑modal) — version 9.7.0 (you said you can’t upgrade because your app is on React 17)
- Platform: Web (React v17)
- Ethers/provider info: error message shows providers/5.7.2 (ethers v5.7.2)
- Error observed when calling switchChain after Google (social) login:
“underlying network changed (event="changed", network={"chainId":84532,"name":"unknown"}, detectedNetwork={"name":"sepolia","chainId":11155111,"ensAddress":null}, code=NETWORK_ERROR, version=providers/5.7.2)”
What this usually means
- The provider’s network changed while ethers was using the old network — ethers throws NETWORK_ERROR when a network change is detected mid-request.
- Common causes: using a decimal chainId instead of hex in wallet_switchEthereumChain params, not adding the chain first (error 4902), or not reinitializing your ethers/web3 provider after chain change.
Quick troubleshooting & fixes to try (worked patterns for web3auth v9.x + ethers v5)
-
Use provider.request with a hex chainId. Example (no-modal web3auth provider):
await web3auth.provider.request({
method: ‘wallet_switchEthereumChain’,
params: [{ chainId: ‘0x14A34’ }] // hex for decimal 84532
}) -
If the chain is not added (error code 4902), call wallet_addEthereumChain first (example skeleton):
await web3auth.provider.request({
method: ‘wallet_addEthereumChain’,
params: [{
chainId: ‘0x14A34’,
chainName: ‘MyChain’,
nativeCurrency: { name: ‘ETH’, symbol: ‘ETH’, decimals: 18 },
rpcUrls: [‘https://your-rpc.example’],
blockExplorerUrls: [‘https://explorer.example’]
}]
}) -
Recreate your ethers provider after switching chains. For example:
// after switch/chainChanged
const ethersProvider = new ethers.providers.Web3Provider(web3auth.provider);
const signer = ethersProvider.getSigner(); -
Listen for chain changes and update state/provider:
web3auth.provider.on && web3auth.provider.on(‘chainChanged’, (chainIdHex) => {
// rebuild provider/signer and update app state
}); -
Avoid firing other requests during the switch. The NETWORK_ERROR often happens when something is mid-request while the network flips.
What I need from you to help further (only if you can share — no spam):
- Your code snippet that initializes web3auth and your provider (the login snippet) and the exact switchChain/addChain call you’re using.
- Are you using ethers.js or web3.js in your app? If ethers, which version (the error suggests v5.7.2).
- Browser console logs (full stack trace) or a screenshot of the console error.
- Which chain are you attempting to switch to (name, decimal chainId and RPC URL) so we can verify the exact chainId hex to use.
If you want, paste your init + switch code and I’ll point out exactly what to change. If you just want a quick test: try calling wallet_switchEthereumChain with a hex chainId and recreate the ethers provider after the switch — that often resolves the underlying network changed error.
I’ll wait for your code/console output and can give an exact patch for v9.7.0.
Note: This response was generated by an AI bot and may require further verification. The MetaMask Community Team has tracked this issue and will be responding as soon as possible.
Additionally, we would recommend you to join our biweekly Office Hours to get this resolved even faster. MetaMask Developer Office Hours