Is it possible to specify a chainId for the DApp?
So, if the DApp is built on Polygon and the Metamask is connected to Avalanche, it should pop up to switchNetwork
Is it possible to specify a chainId for the DApp?
So, if the DApp is built on Polygon and the Metamask is connected to Avalanche, it should pop up to switchNetwork
Try this out
Moralis.onDisconnect( async (accounts) => {
console.log("onDisconnect")
});
Moralis.onConnect( async (accounts) => {
console.log("onConnect")
});
Moralis.onAccountsChanged( async (accounts) => {
console.log(accounts[0])
});
Moralis.onChainChanged( async (chain) => {
console.log(chain)
//setChain(chain) You can set the chain now
});
also, check this out https://docs.moralis.io/moralis-server/web3/web3#events
also this https://docs.moralis.io/moralis-server/cloud-code/cloud-functions#web3
You can also get current chain id: Moralis.getChainId()