[SOLVED] Metamask testnet connection

Hi,

This is more of an exploratory queries. Just wanted to understand:

  1. Is there any function exists which will directly tell my application if metamask(MM) is installed or not. I saw this function somewhere isMetaMaskInstalled(), but it seems its not valid anymore.

  2. While using Moralis.authenticate() function, is there a way to enforce a user to login to mainnet or testnet specifically. Say if I configure for testnet, and in case user is on mainnet on MM, it should directly move the user to testnet (if its configured in their MM account), or throw some kind of error, like ‘You need to change MM to connect to testnet

for second question, you can check current network and display a text when the user is not connected to your preferred network.

for first question, it should work with isMetaMaskInstalled= await Moralis.isMetaMaskInstalled() with latest version of the SDK

1 Like

how to check the current network? is there any moralis method for this as well?

you can try: Moralis.getChainId()

1 Like

worked like a charm! thanks a lot @cryptokid