Skip to main content

Try it Live

Run Chain examples in the interactive playground
Conceptual Guide - For API reference and method documentation, see Chain API.
Ethereum chain IDs are unique numeric identifiers for blockchain networks that prevent replay attacks and enable multi-chain transaction signing. This guide covers chain ID fundamentals using Tevm.

What Are Chain IDs?

A chain ID is a numeric identifier that uniquely identifies an Ethereum network. Every blockchain network (mainnet, testnet, L2, sidechain) has its own chain ID. Common Chain IDs:
  • Ethereum Mainnet: 1
  • Sepolia (testnet): 11155111
  • Goerli (testnet, deprecated): 5
  • Polygon: 137
  • Optimism: 10
  • Arbitrum One: 42161
  • Base: 8453

Why Chain IDs Exist

Chain IDs solve the replay attack problem introduced by EIP-155. Before EIP-155, a transaction signed on one network could be replayed on another network with identical account state.

Replay Attack Scenario (Pre-EIP-155)

EIP-155 Solution

EIP-155 requires chain ID in transaction signatures, preventing cross-chain replay:

Chain ID in Transactions

Chain IDs are signed into transactions, making them network-specific:

Network Identification

Use chain IDs to identify network type:

Validating Network

Check if transaction matches expected network:

Testnet Detection

Identify testnet vs mainnet programmatically:

Network Identification vs Security

Network identification (chain metadata) and replay protection (chain ID in signature) serve different purposes:

Resources

Next Steps