Skip to content
On this page

switchChain

Switch the target chain in a wallet.

Usage

ts
import { avalanche } from 'viem/chains'
import { walletClient } from './client'
 
await walletClient.switchChain({ id: avalanche.id }) 
ts
import { createWalletClient, custom } from 'viem'

export const walletClient = createWalletClient({
  transport: custom(window.ethereum)
})

Parameters

id

  • Type: number

The Chain ID.

JSON-RPC Methods

eth_switchEthereumChain

Released under the MIT License.