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.
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