Skip to main content
MetaMask

wallet_switchEthereumChain

Summary: Switches the wallet's active Ethereum chain.

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

Parameters

SwitchEthereumChainParameter object
required

SwitchEthereumChainParameter

chainId string

The chain ID as a 0x-prefixed hexadecimal string, per the eth_chainId method.

Returns

SwitchEthereumChainResult null

Errors

Code
Message
4902
Unrecognized chain ID. Try adding the chain using wallet_addEthereumChain first.
Customize request
Parameter
Value
string
Connect your MetaMask wallet to run requests successfully.
Request
await window.ethereum.request({
"method": "wallet_switchEthereumChain",
"params": [
{
chainId: "0x64"
}
],
});
Example response
null