Skip to content

Bug: Switch chain ID #23

@mrosendin

Description

@mrosendin

Describe the bug

Unable to switch chain ID using wagmi's useSwitchNetwork

Steps

  1. Set up config like in the wagmi connector docs example with base and baseSepolia chains*
  2. Connect wallet as shown in the docs example
  3. Call switchChain to baseSepolia.id (assuming we are connected to base mainnet)
  4. Log chainId in the console using useChainId hook to confirm chain ID has not switched.

I've created a reproducible example here: https://github.com/mrosendin/smart-wallet-expo-switchChain


*I've installed client v0.1.1 and wagmi-connectors v1.0.0 and appChainIds property in the metadata object for createConnectorFromWallet is not recognized, so I removed it. Here's the error message:

Object literal may only specify known properties, and 'appChains' does not exist in type 'StrictOmit<AppMetadata, "appChainIds">'.

This error msg is at odds with the docs example.

Expected behavior

Connector switches chain and useChainId returns the updated chain ID.

The chain ID will switch only after a hard refresh in Expo Go

Version

client v0.1.1, wagmi-connectors v1.0.0

Additional info

No response

Desktop

No response

Smartphone

  • Device: iPhone 13
  • OS: iOS 17.6.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions