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.