Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
wallet_switchEthereumChain – 1auth
Skip to content

wallet_switchEthereumChain

Changes the active network to a different supported chain. The switch is instant and doesn't require user approval. After switching, subsequent transactions will target the new chain. Use this when your dApp needs to operate on a specific network.

Try it

Parameters

PositionTypeDescription
0objectObject containing chainId

Parameter Object

FieldTypeDescription
chainIdstring | numberThe chain ID (hex string or number)

Returns

null - Returns null on success.

Example

// Switch to Polygon (chainId: 137)
await provider.request({
  method: 'wallet_switchEthereumChain',
  params: [{ chainId: '0x89' }], // 137 in hex
});
 
// Or using a number
await provider.request({
  method: 'wallet_switchEthereumChain',
  params: [{ chainId: 137 }],
});

Events

After switching, the provider emits:

provider.on('chainChanged', (chainId) => {
  console.log('Switched to chain:', chainId);
});

Supported Chains

The provider supports all chains configured in the 1auth registry. Common chains include:

  • Ethereum Mainnet (0x1)
  • Polygon (0x89)
  • Arbitrum (0xa4b1)
  • Optimism (0xa)
  • Base (0x2105)

Notes

  • Chain switching is instant - no user approval required
  • Unsupported chain IDs will throw an error