Error "Failed to fetch project config: Cannot read properties of undefined (reading 'decode')"

When asking for help in this category, please make sure to provide the following details:

  • SDK Version: 7.0.1
  • Platform: React Native
  • Browser Console Screenshots:
    image

Hey everyone! I’m currently using Expo for my project, mainly the web version. The React Native SDK integration looks great, but when I call the init() method after the setup configuration it throws an error “Failed to fetch project config: Cannot read properties of undefined (reading ‘decode’)”

Here’s my setup code that I did based on Web3Auth docs:

useEffect(() => {
    const init = async () => {
      await web3auth.init();

      if (web3auth.privKey) {
        await ethereumPrivateKeyProvider.setupProvider(web3auth.privKey);
      }
    };
    init();
  }, []);

  const redirectUrl =
    Constants.appOwnership == AppOwnership.Expo ||
    Constants.appOwnership == AppOwnership.Guest
      ? Linking.createURL("web3auth", {})
      : Linking.createURL("web3auth", { scheme: "web3authexpoexample" });

  const clientId =
    "BLp6-z-fTRXLQsKHPcXvITV9ckcNe1mO5kzdLXdui-NNEPbTVrxmdQddXLilhGaZBPCaTgjZ4ljUMzQpi5Ct4GU";

  const ethereumPrivateKeyProvider = new EthereumPrivateKeyProvider({
    config: {
      chainConfig: {
        chainNamespace: CHAIN_NAMESPACES.EIP155,
        chainId: "0x1",
        rpcTarget: "https://rpc.ankr.com/eth",
        displayName: "Ethereum Mainnet",
        blockExplorerUrl: "https://etherscan.io",
        ticker: "ETH",
        tickerName: "Ethereum",
      },
    },
  });

  const web3auth = new Web3Auth(WebBrowser, SecureStore, {
    clientId,
    redirectUrl,
    network: OPENLOGIN_NETWORK.SAPPHIRE_DEVNET,
  });

Hi Lucas! Thanks for reaching out to the community for help. I see you’re facing an error with the PnP React Native SDK while trying to initialize Web3Auth. Let’s gather the details to make it easier for the support team to assist.

Error Details

  • SDK Details: PnP React Native SDK
  • SDK Version: 7.0.1
  • Platform: React Native
  • Error Message: “Failed to fetch project config: Cannot read properties of undefined (reading ‘decode’)”
  • Browser Console Screenshot: Console Screenshot

Initialization Code Snippet

You’ve provided your setup code, which is great! However, if you can share the following as well, it would help us narrow down the issue:

  • The Web3Auth initialization code snippet (which you have shared).
  • Any additional details about your environment, like if you’re using any specific configuration for Expo.

Possible Suggestions:

While I gather the details, you might want to check:

  • Ensure that all dependencies are properly installed and compatible with SDK version 7.0.1.
  • Verify your clientId is correctly set up in the Web3Auth dashboard.

If you could provide any additional code snippets related to your initialization or any other settings you’ve configured, that would be helpful. Thank you, and let’s get this sorted out!

Note: This response was generated by an AI bot and may require further verification. The Web3Auth support team has tracked this issue and will be responding as soon as possible.