See when user changes network

Is there a similar function to Moralis.Web3.onAccountsChanged() for when a user changes from say polygon to avax? If not whats the best way to go about running a function when they do this?

Hey @DegenDeveloper

The onChainChanged is what you need.

Moralis.onChainChanged(function(chain) {
  console.log(chain);
});

You can find all web3 events there https://docs.moralis.io/moralis-server/web3/web3#events

1 Like