How to handle chain changes made by the user with Metamask

I’m currently using MetaMask as sign-in option and using Sepolia as the selected chain. So if I call web3auth.connected it returns true.

However, if I manually switch my chain on the MetaMask extension for Goerli for example, web3auth.connected will return false and web3auth.provider is null even though I refresh my page. And the only way that I found to fix this is by doing sign out and sign in.

Is there any other way to fix this?

Hi @felipe ,
I hope you are doing good !

Have you considered using web3.js to listen for the network changes event? This approach could potentially help in automatically handling the chain switch.

Yeah I ended up doing that. I was just wondering if that was possible just by using the web3auth SDK.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.