Try it Live
Run Transaction examples in the interactive playground
getChainId
Extract chain ID from transaction.Chain ID Extraction
Typed Transactions
For typed transactions (EIP-2930, EIP-1559, EIP-4844, EIP-7702), chain ID is explicitly included:Legacy Transactions
For legacy transactions, chain ID is encoded in thev value per EIP-155:
Pre-EIP-155 Transactions
Pre-EIP-155 legacy transactions use simple v values (27 or 28):Usage Patterns
Replay Protection
Cross-Chain Detection
Transaction Filtering
See Also
- Hashing - Transaction and signing hash computation
- Signing - Signature verification and sender recovery
- getGasPrice - Get effective gas price
- format - Format transaction for display
References
- EIP-155: Simple replay attack protection
- EIP-2718: Typed Transaction Envelope
- Chain IDs - Comprehensive list of EVM chain IDs

