Ethereum
Switch chains
To switch the network of a connected wallet, first find the corresponding ConnectedWallet
object from the wallets
array.
Then, call the wallet’s switchChain
method. As a parameter to the method, pass the chain ID for your desired network as a number
or hexadecimal string
:
For embedded wallets, switchChain
will update the network of the embedded wallet behind the scenes. For external wallets, switchChain
will prompt the user to switch to the target network within the external wallet’s client (e.g. their browser extension or mobile app).
switchChain
returns a Promise that resolves to void
once the wallet has successfully been switched to the target network. The Promise will reject with an error if:
- The target chain has not been configured.
- The user declines the request to switch their network, if using an external wallet.
Was this page helpful?