Skip to content

Problem: Switch chain to Mainnet with Metamask (QR) not working #21

Description

@teodorus-nathaniel

How to reproduce:

  • Connect metamask with QR (or wallet connect QR but with metamask mobile app)
  • Put other chain data to chain parameter in WalletConnectModal. If the chain is undefined, then don't put "locked chains" (the locked chains list below) in the first element of chains
  • Switch your metamask wallet connected chain to any chain other than the "locked chains"
  • Call wallet.switchChain(...) to "locked chains".
  • It will cause error May not specify default Metamask chain.
    image

Locked Chains List

  • Eth Mainnet
  • Eth Sepolia
  • Linea
  • Linea Sepolia
    image

Issue Detail

In thirdweb if the chain is not included in approved list, then the flow is:

  1. Call wallet_addEthereumChain
  2. Call wallet_switchEthereumChain

In this case, metamask will throw error if you try to call wallet_addEthereumChain with arg of either one of the locked chains.

Another Related Issue

thirdweb uses @walletconnect/ethereum-provider under the hood to create the provider that also saves the approved chains list.
This library will only include the below ids as approved:

  1. provided chainId from chain props
  2. the current connected chain that user have in their metamask

This makes an issue where if the app is multichain, for example Sepolia and Ozean, and the app wants the user to connect to Ozean first, then we need to put Ozean as the chain props.
Which in turn will create an error when the user wants to switch to Sepolia.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions