detect-provider
detect-provider copied to clipboard
No provider selected for request eth_chainId when coinbase wallet extension is installed
Repro: Install Coinbase Wallet
const prov: any = await detectEthereumProvider({ mustBeMetaMask: true });
const chainId: string = await prov.request({ method: 'eth_chainId' });
Error: No provider selected for request eth_chainId
From the docs: This may happen, for example, if the user has multiple wallets installed. After confirming that your code and dependencies are not modifying or overwriting window.ethereum, you should ask the user to ensure that they only have a single provider-injecting wallet enabled at any one time.
Any solutions other than messaging?
Any progress on this? I'm having a similar issue.
This helped: https://ethereum.stackexchange.com/questions/111605/how-can-i-connect-my-dapp-to-metamask-if-coinbase-wallet-injects-another-ethere
useEffect(() => {
if (isMetaMaskInstalled()) {
if (window.ethereum.providers.length > 1) {
const metamaskProvider = window.ethereum.providers.find((provider) => provider.isMetaMask);
window.ethereum = metamaskProvider;
}
}
}, []);