0

I am trying to build an app with web3js. I use JavaScript for connecting the app to wallet.

const accounts = await web3.eth.requestAccounts().catch((error) => {
    $('#walletErrorMsg').html(error.message);
    $('#walletErrorModal').modal('show');
});

This is my code to connect app to wallet. This code works perfectly. But now I want to connect only with MetaMask. No support for other wallets. How can I connect only with meta mask ? Is there any solution for this? Thanks in advance.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Amal S R
  • 870
  • 7
  • 21

1 Answers1

0

You can validate against window.ethereum.isMetaMask.

There is a high probabiliy of other wallets not setting this property and not returning true.

Docs: https://docs.metamask.io/guide/ethereum-provider.html#ethereum-ismetamask

Petr Hejda
  • 40,554
  • 8
  • 72
  • 100