walletconect v2 chains not supported
Describe the bug
I have Error: Unsupported chains. after init @walletconnect/ethereum-provider with chains length > 1
await EthereumProvider.init({
projectId: walletConnectProjectId,
walletConnectVersion: 2,
chains: [Web3Chains.Ethereum, Web3Chains.Goerli]})
To Reproduce Steps to reproduce the behavior
- call
initaction from @walletconnect/ethereum-provider withchains: [Web3Chains.Ethereum, Web3Chains.Goerli] - connect metamask mobile wallet with walletconnect v2
- See error in console Error: Unsupported chains
Expected behavior Metamask mobile wallet should be connected without any error
Smartphone (please complete the following information):
- Device: Redmi note 8
- OS: Android
- App Version v7.0.1(1126)
to be added after bug submission by internal support / PM Severity
- How critical is the impact of this bug on a user?
- Add stats if available on % of customers impacted
- Is this visible to all users?
- Is this tech debt?
Having the same problem with chains: [137] for Poly
Having the same problem with chains: [7001] for ZetaChain Testnet
I was facing the same problem and bypassed it by setting my chains as optional.
EthereumProvider.init({
// other config properties
chains: [1], //need to have at least one, so I set mainnet chainId
optionalChains: [5, 7001] // add here all your chains
})
If you add the chainids to the optionalChains you are able to connect, but afterwards you are not able to switch to the defined optional chains.
Also the error happens when you provide more than one chain in the chains prop.
EthereumProvider.init({
// other config properties
chains: [1, 5], //need to have at least one, so I set mainnet chainId
optionalChains: [7001] // add here all your chains
})
And it won't work.
Hello, @andriirak. Thanks for reporting! I will pass this on to the team.
Facing the same issue. Fixed it by passing optionalChains.
Check out this discussion:
https://github.com/orgs/WalletConnect/discussions/2920
@anaamolnar hi, any news, when will it be ready?
Facing the same issue. Fixed it by passing
optionalChains. Check out this discussion: https://github.com/orgs/WalletConnect/discussions/2920
Fixing it with optionalChains doesn't really fix it. Problem using that approach is that after you connect and then want to switch chains it won't work. Either you'll get an error saying "Error: Failed to switch to chain 'eip155:1'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method" or you'll just get a positive resolution (null) but the chain in the Metamask won't change at all.
@anaamolnar is there any progress on this issue?
Using multiple chains just won't let us connect our mobile MM apps with our dapps.
Using optionalChains rises other issues..
So we're very much interested into solving this one.
Happens with Metamask Android and iOS apps ver 7.3.0 using latest "@web3-react/walletconnect-v2": "8.3.7"
ps: using Metamask browser extension, all works well.
Any updates on this issue? It's blocking dApps that support multiple chains from fully integrating with Metamask Mobile via Wallet Connect.
Any updates? This has being a major pain since the wallet-connect migration to v2.
Having the same problem for 719 (Shiba Inu Testnet)
Please update MetaMask to version 7.4.x should be fixed
Hi @glitch-txs
I am on
Metamask Mobile: v7.5.0 (1167) and
"@walletconnect/ethereum-provider": "^2.10.0",
"@walletconnect/modal": "^2.6.1",
<script setup lang="ts">
import { EthereumProvider } from '@walletconnect/ethereum-provider'
const handleConnect = async () => {
try {
const provider = await EthereumProvider.init({
projectId: 'foo',
chains: [1, 42220],
showQrModal: true,
})
await provider.enable()
console.log(provider.accounts)
} catch (error) {
console.log(error)
}
}
</script>
<template>
<div>
<h1>Walletconnect + Metamask</h1>
<button type="button" @click="handleConnect">Conectar</button>
</div>
</template>
And the "Error: Unsupported chains." still there.
https://github.com/MetaMask/metamask-mobile/assets/43136874/074a5049-5418-4aca-a995-7f6840a80e44
@paro-paro MetaMask only supports one required chain, you need to move the rest to optionalChains
@glitch-txs thanks!
I understand that the 7.4.x fix was related to the "Error: Failed to switch to chain 'eip155:1'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method"
I check it out and it seems to be working fine so sorry for my confusion.
Still, I have found another issue related to the walletconnect + metamask-mobile integration.
Steps to reproduce:
- Init your ethereum provider with two networks (ETH and CELO)
const provider = await EthereumProvider.init({
projectId: 'foo',
chains: [1],
optionalChains: [42220], // celo
showQrModal: true,
})
-
Connect you metamask mobile wallet by scanning the QR code (make sure metamask is connected to Ethereum Mainnet).
-
Switch to CELO network from the dapp with the
wallet_switchEthereumChainmethod.
await provider.request({
method: 'wallet_switchEthereumChain',
params: [
{
chainId: '0xa4ec',
},
],
})
- Trigger a
personal_signrequest.
So far, so good.
Metamask will connect successfully to the dapp (2), the wallet_switchEthereumChain will prompt the user to change the network to CELO (3) and the personal_sign prompt will also be displayed in the metamask wallet (4).
But, once in this state, if the user...
- Switches back to ETH network.
In this case, metamask will not prompt the user to change the network but the provider will effectively reflect this change on the chainChanged event. I believe this is expected behaviour (changing again to CELO will behave the same way, not prompting the user but reflecting the change in the provider).
- Triggers again the
personal_signrequest.
Here is when I find the problem:
Metamask will properly detect that the provider is connected to ETH and before displaying the personal_sign prompt, will ask the user to change the network first (since metamask is still connected to CELO).
But after that, it wont sequentially display the sign prompt. The user will have to trigger again the personal_sign request (by, for example, clicking the sign message button twice which is unintuitive and feels like the dapp is not working).
Fortunately, this is the expected behaviour we get if the user switches again to the CELO network and launches the sign request:
=> Metamask will prompt the user for a network change (really nice) and right after that will prompt the sign request (so perfect).
You can find a reproduction repo here in case is useful.
Thanks in advanced.
Maybe I should open a different issue for this @glitch-txs ?
@paro-paro could you post this on a new MetaMask issue? I was actually about to QA this exact flow. Thanks! 🤝
Great @glitch-txs ! 😄
Here it is https://github.com/MetaMask/metamask-mobile/issues/7138
Thanks a lot!!
This issue has been automatically marked as stale because it has not had recent activity in the last 90 days. It will be closed in 7 days. Thank you for your contributions.
any updates?