I want to detect which wallet provider has been used to connect to a specific dApp.

right now what I'm doing is

const ethereum = window.ethereum;
const web3 = window.web3;

if (ethereum && ethereum.isMetaMask) {
  console.log('Connected to MetaMask');
} else if (web3 && web3.currentProvider && web3.currentProvider.isCoinbaseWallet) {
  console.log('Connected to Coinbase Wallet');
} else if (web3 && web3.currentProvider && web3.currentProvider.isWalletConnect) {
  console.log('Connected to WalletConnect');
} else {
  console.log('Connected to an unknown wallet provider');

but the problem with this approach is, I can't detect which particular wallet has been used to connect to the dApp. When the user has multiple wallet providers installed, both ethereum.isMetaMask and `web3.currentProvider.isCoinbaseWallet may be true, so the above code cannot determine which specific wallet provider was used to connecting to the dapp.

Is there a way to detect the specific wallet provider used by the user when multiple wallet providers are installed? Can I listen for events or access properties to determine the specific wallet provider used by the user?

2 Answers 2


This is atm natively not possible.

You could go the other way around:

The way sushi solved this, is by asking you to before connecting which provider you want to use. After choosing, they will open the corresponding wallet provider. Sushi uses use-wallet for that. If you are interested doing it natively, you can check out the use-wallet source code.

If you don't care about using a third-party service:

There is an awesome service called WalletConnect that does this automatically for you. Every wallet I know supports it and it has a good documentation as well as an easy API. It also provides either a standardized UI for easy user recognition but there is also the option that leaves the frontend up to you.

You will just interact with a unified API and don't have to care about the underlying wallet provider anymore.

  • Thanks for the comment bro. But in my use case, I want to know the wallet provider, without any 3rd party library. I need to write a script that does the same with the native browser APIs. Mar 30, 2023 at 7:49
  • Updated the comment accordingly.
    – Throvn
    Mar 30, 2023 at 8:36

The code you share only checks which wallets are available in the browser.

When the user selects which wallet to use, he/she clicks a button with Metamask/coinbase/walletconnect logo, and your code will know what wallet is chosen.

When the user sends an tx, your front-end code sends the following request:

Provider.request(args: RequestArguments): Promise<unknown>;

You should be able to check the provider by calling

  • provider.isMetaMask
  • provider.isCoinbaseWallet
  • provider.isWalletConnect

Your Answer

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

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