WalletConnect Adapter giving error on connection 'Missing or invalid.'

  • I try to use walletconnect login
  • I use mobile Metamask to take picture of the QR code
  • Metamask asks if I want to connect to the site
  • Signing fails in browser (error): Login failed: JsonRpcError: Missing or invalid. request() chainId: eip155:8453

I only have Base blockchain selected - is this the reason that it is failing? If I understand correctly it should propose to add the chain if it is missing? Or is the logic that auth should only specify Ethereum Mainnet (0x1)?

index.92c53fec.js:1  Login failed: JsonRpcError: Missing or invalid. request() chainId: eip155:8453
    at getJsonRpcError (errors.js:38:10)
    at Object.internal (errors.js:87:20)
    at r.sendAsync (jrpcEngine.js:395:23)
    at async r.request (jrpcEngine.js:416:11)
    at async WalletConnectV2Adapter._getSignedMessage (walletConnectV2adapter.js:354:11)
    at async WalletConnectV2Adapter.authenticateUser (walletConnectV2adapter.js:200:13)
    at async Proxy.sendWeb3AuthTokenToXano (index.92c53fec.js:1:23357)
    at async e (index.92c53fec.js:1:22323)

Code:

            const defaultWcSettings = await getWalletConnectV2Settings(
                "eip155",
                ["0x2105"],
                this.content.walletConnectProjectId,
            );
            const walletConnectModal = new WalletConnectModal({
                projectId: this.content.walletConnectProjectId,
            });
            const walletConnectV2Adapter = new WalletConnectV2Adapter({
                adapterSettings: { qrcodeModal: walletConnectModal, ...defaultWcSettings.adapterSettings },
                loginSettings: { ...defaultWcSettings.loginSettings },
            });
            
            web3auth.configureAdapter(walletConnectV2Adapter);

Hi Silver Sepp! Thank you for reaching out with your issue regarding the WalletConnect adapter. I understand how frustrating it can be to encounter these kinds of errors.

Here’s a summary of the details you’ve provided:

  • SDK Details: PnP Web SDK
  • Issue: WalletConnect Adapter giving error on connection ‘Missing or invalid.’
  • Error Message: Login failed: JsonRpcError: Missing or invalid. request() chainId: eip155:8453
  • Steps to Reproduce:
    1. Using WalletConnect to log in.
    2. Scanning the QR code with mobile MetaMask.
    3. MetaMask prompts for connection.
    4. Signing fails with the mentioned error.

Code Snippet:

You provided the following code snippet for configuring the WalletConnect adapter:

const defaultWcSettings = await getWalletConnectV2Settings(
    "eip155",
    ["0x2105"],
    this.content.walletConnectProjectId,
);
const walletConnectModal = new WalletConnectModal({
    projectId: this.content.walletConnectProjectId,
});
const walletConnectV2Adapter = new WalletConnectV2Adapter({
    adapterSettings: { qrcodeModal: walletConnectModal, ...defaultWcSettings.adapterSettings },
    loginSettings: { ...defaultWcSettings.loginSettings },
});

web3auth.configureAdapter(walletConnectV2Adapter);

Proposed Solution:

It seems like the issue may be related to the chain ID you’ve specified. The error suggests that the chain ID being used (eip155:8453) is not being recognized or is invalid. Ensure that:

  1. The chain ID being sent during the request is supported and correctly configured in both your application and the WalletConnect settings.
  2. If using Base blockchain, confirm that it is correctly set up and supported by WalletConnect.

Additionally, if you want WalletConnect to propose adding the chain, make sure that your WalletConnect configuration is set up to allow for that.

Next Steps:

  • Please check if you can modify the chain ID and see if that resolves the issue.
  • If the problem persists, could you provide us with any browser console screenshots? They might give us more insight into the error.

Feel free to reach out with any further questions or clarifications! We’re here to help.

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.

Just FYI, this is how the chainConfig is initialized:

          const chainConfig = {
                chainNamespace: CHAIN_NAMESPACES.EIP155,
                chainId: "0x2105",
                displayName: "Base Mainnet",
                rpcTarget: "https://mainnet.base.org",
                blockExplorerUrl: "https://base.blockscout.com",
                ticker: "ETH",
                tickerName: "Ethereum",
                logo: "https://github.com/base-org/brand-kit/raw/main/logo/in-product/Base_Network_Logo.svg",
            };

            const privateKeyProvider = new window.EthereumPrivateKeyProvider({
                config: { chainConfig },
            });
            
            const web3AuthOptions = {
                clientId,
                web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_DEVNET,
                privateKeyProvider,
                sessionTime: 604800
            };

This same chainconfig works with MEtamask wallet for example. It asks to add the missing chain. But not the WalletConnect adapter.

Hey @silver,
Thanks for providing the details. To help us better diagnose the issue, could you please submit a recording of the process using jam.dev? This will allow us to see exactly which call is failing and what the response looks like.

Can I post the recording somewhere privately?

When you click on the avatar next to my name, you’ll see an option to message me, please DM me the link.

Sorry but there is no way to message you. I think perhaps only admins can private message people? Can you please message and I will respond to you?

Btw, it seems that even if I have the chain in mobile Metamask but it is not active, then WalletConnect adapter will throw an exception. Only when I previously have the chain active it seems to work.

@maharshi could you please send me a PM, I will respond with the link

Dm’d you, please check your messages.