Skip to main content

wallet_switchEthereumChain

MetaMask

Requests that the wallet switches its active Ethereum chain. Introduced by EIP 3326.

Params

(1)

1. SwitchEthereumChainParameter (required)

chainId
string
required

MUST specify the integer ID of the chain as a hexadecimal string, per the eth_chainId Ethereum RPC method.

Result

(SwitchEthereumChainResult)
null

Errors

CodeMessage
4902Unrecognized chain ID. Try adding the chain using `wallet_addEthereumChain` first.

Example

Request

await window.ethereum.request({
"method": "wallet_switchEthereumChain",
"params": [
{
"chainId": "0x64"
}
]
});

Result

"null"

Params

SwitchEthereumChainParameter


Request

await window.ethereum.request({
"method": "wallet_switchEthereumChain",
"params": [
null
]
});