Skip to main content

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 the v 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