{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "wallet_switchEthereumChain",
  "params": [{
    "chainId": "0x2105"
  }]
}
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": null
}

Defined in EIP-3326

Requests that the wallet switches its active Ethereum chain to one of the chains already added to the wallet.

Parameters

chainId
string
required

A 0x-prefixed hexadecimal string representing the chain ID of the chain to switch to.

Returns

result
null

Returns null if successful.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "wallet_switchEthereumChain",
  "params": [{
    "chainId": "0x2105"
  }]
}
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": null
}

Error Handling

CodeMessageDescription
4001User rejected the requestUser denied switching chains
4100Requested method not supportedThe method is not supported by the wallet
4902Unrecognized chain IDThe requested chain has not been added to the wallet

If the chain is not already added to the wallet, use wallet_addEthereumChain first.

Switching chains will affect all subsequent blockchain operations in your application.