1

In the DAPP I am building I want to let users log in with their wallet of choice. Currently I have two wallets, Metamask and coinbase wallet. The function window.ethereum.enable() injects web3 globally and therefore both the chrome extensions pop up. How can I choose which wallet to pop up on the click of the user and there on do transactions with that wallet only

1 Answer 1

0

You should be able to show a modal with multiple wallets, and then let the user choose. You can check web3Modal as it makes it way easier to do what you want, of course, if you are making a web Dapp.

Also, there is a window.ethereum.isMetamask variable that can differentiate between metamask and other wallets. But this is always in the hands of the wallet your user is using, as a wallet can create that variable is set it to true even if it's not metamsk.

4
  • Yes at the moment I am showing a modal with the two wallet names. Bu the thing is to open both of them the same function window.ethereum.enable() is used. Therefore both the modals pop up. Any solution to that? Jan 16, 2022 at 14:40
  • @Sol_lover i mentioned the window.ethereum.isMetamask variable, that you can use to differentiate between metamask and other wallets Jan 16, 2022 at 15:06
  • According to the documentation window.ethereum.isMetamask returns true when metamask is installed. But my use case here is different. I present two buttons to the user to connect their wallet to the dapp either using metamask or CoinBase. So when the relevant button is clicked how can only that relevant wallet pop up? ethereum.enable() makes both the installed wallets pop up. Jan 16, 2022 at 17:18
  • If both wallets use the same enable() method, then it shouldn't be your issue. you can't take into consideration any wallet, especially if anybody can create a wallet and make to seem like metamask and implement their popup the same way metamask does. Jan 24, 2022 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.