Skip to content
On this page

switchChain

Switch the target chain in a wallet.

Usage

ts
import { switchChain } from 'viem'

Usage

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

Parameters

id

  • Type: number

The Chain ID.

Released under the MIT License.