web3 connect with differents web3 browser providers

60 views Asked by At

I'm starting on the world of web3 and dapps. Currently I have installed on my browser differents wallets plugins, as Metamask, Trust wallet and XDEFI. In my frontend I would like to connect and get account info from wallets selecting one of them. Currently I'm avalaible to connect only with metamask, because window.ethereum only get info from metamask, no the others wallets. How can I selected which wallet I would like to connect? I'm using ethers v6.11 in my vue project.

1

There are 1 answers

0
sir adek On

Different wallet extensions have different ways and different browser api for connecting to them. If you want to implement each individually, it can get unnecessarily complicated. I'll advice you try out libraries that allows you to connect to multiple different wallets. example of this is web3modal

Take a look at the documentation for vue here https://docs.walletconnect.com/web3modal/vue/about

Update:

You can as well read up on eip-6963. The problem with window.ethereum is that, out of all the wallet extensions you have installed, only one is made available in window.ethereum at a time. eip-6963 gives you the freedom of connecting to any of your installed wallet extensions.

It is a very simple eip. The links below should help you understand it https://eips.ethereum.org/EIPS/eip-6963