web3modal icon indicating copy to clipboard operation
web3modal copied to clipboard

[bug] switchNetwork() fails to switch between Solana and EVM networks for multi-chain wallets

Open cclion opened this issue 4 months ago • 4 comments

Link to minimal reproducible example

https://github.com/your-username/appkit-switch-network-bug-demo Instructions: 1. Clone the repository 2. Run npm install 3. Run npm run dev 4. Connect Phantom wallet to Solana 5. Try switching to Ethereum network 6. Observe address becomes undefined

Steps to Reproduce

  1. Connect a multi-chain wallet (Phantom/OKX) to Solana network
  2. Successfully login and verify address is available
  3. Call switchNetwork(mainnet) to switch to Ethereum
  4. Check useAppKitAccount().address - it becomes undefined
  5. Check useAppKitNetwork() - network state doesn't update properly
  6. Wallet appears disconnected despite successful switch call

Summary

Expected Behavior:

  • switchNetwork() should seamlessly switch between Solana and EVM networks
  • Wallet address should remain available after network switch
  • Network state (caipNetworkId, chainId) should update correctly
  • Multi-chain wallets should maintain connection across different network types

Actual Behavior:

  • Address becomes undefined after switching from Solana to EVM
  • Network state shows inconsistent values (still shows Solana values)
  • Wallet appears disconnected despite successful switchNetwork() call
  • Only works when disconnecting and reconnecting manually

Affected Platforms:

  • Chrome, Safari, Firefox
  • Multi-chain wallets: Phantom, OKX
  • Networks: Solana ↔ Ethereum, Solana ↔ Polygon, etc.

Code Example:

const { address } = useAppKitAccount();
const { switchNetwork } = useAppKitNetwork();

// Before switch: Solana
console.log(address); // "D2WpEKRSQ3tSHzsTVtm1BS5FiGnpapN5u9qsVFtRX86D"

await switchNetwork(mainnet); // Switch to Ethereum

// After switch: EVM
console.log(address); // undefined ❌

Logs:

List of related npm package versions

- @reown/appkit: 1.8.6
- @reown/appkit-controllers: 1.8.6
- @reown/appkit-common: 1.8.6
- wagmi: 2.37.7
- viem: 2.37.7
- react: 18.2.0
- next: 14.0.0

Node.js Version

v18.17.0

Package Manager

pnpm 8.15.0

cclion avatar Sep 27 '25 07:09 cclion

hi @cclion

Can you checks if it's working here ? https://appkit-web-examples-react-multichain.reown.com/

https://github.com/reown-com/appkit-web-examples/tree/main/react/react-multichain

rtomas avatar Sep 28 '25 01:09 rtomas

Can you checks if it's working here ? https://appkit-web-examples-react-multichain.reown.com/

For me if u connect wallet on this demo u can switch between mainnet and solana but u couldnt switch between mainnet and arbitrum. Seems like during switch it call wrong rpc (https://rpc.walletconnect.org/v1/?chainId=solana... from network)?

sakhro avatar Oct 16 '25 21:10 sakhro

For me if u connect wallet on this demo u can switch between mainnet and solana but u couldnt switch between mainnet and arbitrum. Seems like during switch it call wrong rpc (https://rpc.walletconnect.org/v1/?chainId=solana... from network)?

Same issue (with RPC endpoint) for transaction send if solana and evm configured. When Im trying to send transaction with WC wallet on evm network it will set chainId=solana

sakhro avatar Oct 18 '25 13:10 sakhro