Skip to content

[Arc Testnet quirk] wallet_switchEthereumChain returns success without actually switching #1

Description

@osr21

Symptom

On Arc Testnet, calling wallet_switchEthereumChain sometimes returns a resolved promise (no error thrown) while the wallet stays on the previous chain. Standard code that trusts the promise resolution will silently send transactions to the wrong network.

Affected versions

  • MetaMask (all recent versions tested against Arc Testnet chain ID 5042002)
  • Likely affects all wallets that pass through Arc's custom RPC

Reproduction

await window.ethereum.request({
  method: 'wallet_switchEthereumChain',
  params: [{ chainId: '0x4CEF52' }], // Arc Testnet
});
// ⚠️  Promise resolved — but current chain may NOT be Arc yet
const chainId = await window.ethereum.request({ method: 'eth_chainId' });
console.log(chainId); // May still be the old chain!

Workaround

Always verify the active chain ID after the call. If the chain didn't switch, fall back to wallet_addEthereumChain (which adds and switches atomically):

await window.ethereum.request({ method: 'wallet_switchEthereumChain', params: [{ chainId }] });
const actual = parseInt(await window.ethereum.request({ method: 'eth_chainId' }), 16);
if (actual !== expectedChainId) {
  // Fall through to wallet_addEthereumChain
  await window.ethereum.request({ method: 'wallet_addEthereumChain', params: [chainConfig] });
}

References

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions