Core.mjs:7380 ERROR ProviderNotFoundError: Provider not found

Hi, I had this working a few months back by following this https://docs.moralis.com/authentication-api/evm/how-to-sign-in-with-metamask-angular. Now in mobile browser, it’s throwing this error:

core.mjs:7380 ERROR ProviderNotFoundError: Provider not found.
Version: @wagmi/[email protected]
at injected.js:71:23
at Generator.next ()
at asyncGeneratorStep (asyncToGenerator.js:3:1)
at _next (asyncToGenerator.js:17:1)
at _ZoneDelegate.invoke (zone.js:369:28)
at Object.onInvoke (core.mjs:7227:33)
at _ZoneDelegate.invoke (zone.js:368:34)
at ZoneImpl.run (zone.js:111:43)
at zone.js:2538:40
at _ZoneDelegate.invokeTask (zone.js:402:33)

Here is the code snippet
import {
connect,
disconnect,
getAccount,
injected,
signMessage,
} from “@wagmi/core”;
import { http, createConfig } from “@wagmi/core”;
import { fraxtalTestnet, mainnet, sepolia } from “@wagmi/core/chains”;
import { metaMask } from ‘@wagmi/connectors’;

auth() {
return new Observable((observer) => {
(async() => {
const config = createConfig({
chains: [mainnet, sepolia],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
},
connectors: [metaMask({useDeeplink: true})],
});
const { isConnected } = getAccount(config);
const provider = await connect(config, { connector: injected() }); // enabling the web3 provider metamask

    const userData = {
      address: provider.accounts[0],
      chain: provider.chainId,
    };
    observer.next({ user: userData });
    observer.complete();

})
}

Hi @playground

Maybe the response is expected. The code that is used to detect the web3 provided on desktop does not work on mobile as mobiles do not have web3 wallet extensions. Try using wallet connect packages when using mobile browser.

Hi @johnversus, I got it working now. Seems like something changed in the latest version of wagmi, Instead of calling injected(), I call metaMask() directly.

const provider = await connect(config, { connector: metaMask() })

1 Like