EVM

Chain ID

Chain ID is the blockchain network identifier used to separate transactions, signatures, and domains across chains.

Chain ID tells a contract which chain it is on and helps stop cross-chain replay.

Chain ID Explained in Detail

Chain ID identifies the network where code is running. Solidity exposes it as block.chainid. Signatures and transaction formats often include chain ID to prevent reuse on another chain.

In EIP-712, chain ID is usually part of the domain separator.

Smart contract example

uint256 currentChain = block.chainid;

This value can be included in signed data or deployment checks.

Chain ID in Auditing

Without chain ID, a signature or message valid on one chain may be valid on another. That can affect permits, bridge messages, governance actions, and account abstraction operations.

Auditors check whether signed authorizations bind the correct chain and domain.

Red flags in code

  • Signed data omits chain ID.

  • Chain ID is hardcoded incorrectly.

  • Cached domain separators ignore chain changes.

  • Bridge messages confuse source and destination chain IDs.

  • Same contract address is trusted equally on every chain.

How to test or review it

  • Recompute signatures under a different chain ID and expect failure.

  • Review EIP-712 domain separator construction.

  • Check bridge source and destination domain fields.

  • Test fork or deployment scenarios when supported.

  • Verify chain-specific constants are documented and controlled.

Sources