network-wireddomain_separator

Compute EIP-712 domain separator

Compute the EIP-712 domain separator for a given chain ID.

Overview

domain_separator() computes the EIP-712 domain separator, which binds typed data to a specific chain and verifying contract. This prevents cross-chain replay attacks and ensures signatures are only valid in their intended context.

Signature

def domain_separator(chain_id: int) -> bytes

Parameters

Parameter
Type
Required
Description

chain_id

int

Yes

Numeric chain identifier (e.g., 5124 for Seismic testnet)

Returns

Type
Description

bytes

32-byte keccak256 hash of the domain separator

Examples

Basic Usage

from seismic_web3 import domain_separator, SEISMIC_TESTNET

# Seismic testnet
testnet_domain = domain_separator(SEISMIC_TESTNET.chain_id)
print(f"Testnet domain: {testnet_domain.hex()}")

Compare Across Chains

Use in Custom Signing

Verify Chain-Specific

How It Works

The function computes:

Where:

  • Type hash - Hash of EIP712Domain struct type string

  • Name - "Seismic Transaction" (domain name)

  • Version - "2" (matches TYPED_DATA_MESSAGE_VERSION)

  • Chain ID - Numeric chain identifier

  • Verifying contract - 0x0000000000000000000000000000000000000000 (signing is off-chain)

Domain Fields

The domain separator encodes:

Field
Value
Description

name

"Seismic Transaction"

Domain name

version

"2"

Message version

chainId

chain_id parameter

Chain identifier

verifyingContract

0x0...0

Zero address (off-chain signing)

Implementation

Purpose

The domain separator ensures:

  • Chain isolation - Signatures for chain A won't work on chain B

  • Contract binding - Signatures bound to specific verifying contract

  • Replay prevention - Can't reuse signatures across different contexts

Notes

  • Always 32 bytes (keccak256 output)

  • Same for all transactions on the same chain

  • Can be pre-computed and cached per chain

Performance Optimization

Verifying Contract

The verifying contract is set to 0x0000000000000000000000000000000000000000 because:

  • Signing happens off-chain via RPC

  • No on-chain contract verifies the signature

  • The Seismic node verifies the signature directly

See Also

Last updated