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?