codebuild_seismic_typed_data

Build EIP-712 typed data dict for external signers

Build the EIP-712 typed data dict for a Seismic transaction.

Overview

build_seismic_typed_data() constructs a JSON-serializable dictionary matching the format expected by eth_signTypedData_v4 (used by MetaMask, WalletConnect, and other external signers). This enables human-readable transaction signing in wallet UIs.

Signature

def build_seismic_typed_data(tx: UnsignedSeismicTx) -> dict[str, Any]

Parameters

Parameter
Type
Required
Description

tx

Yes

The unsigned Seismic transaction

Returns

Type
Description

dict[str, Any]

Dict with keys types, primaryType, domain, message

Examples

Basic Usage

from seismic_web3 import build_seismic_typed_data, UnsignedSeismicTx
import json

unsigned_tx = UnsignedSeismicTx(...)

# Build typed data
typed_data = build_seismic_typed_data(unsigned_tx)

# Pretty print
print(json.dumps(typed_data, indent=2))

Use with External Signer (MetaMask)

Inspect Structure

Verify Against Manual Hash

Export for Testing

Output Structure

The returned dictionary has this structure:

Field Encoding

types

Defines the structure of both the domain and the message:

  • EIP712Domain - Standard domain fields

  • TxSeismic - All transaction fields with their Solidity types

primaryType

The primary type being signed:

  • Always "TxSeismic" for Seismic transactions

domain

Identifies the signing context:

  • name - "Seismic Transaction"

  • version - "2" (matches message_version)

  • chainId - Numeric chain identifier

  • verifyingContract - "0x0000000000000000000000000000000000000000" (off-chain signing)

message

All transaction field values:

  • Numeric fields as integers

  • Address fields as checksummed hex strings

  • Bytes fields as "0x" prefixed hex strings

  • Boolean fields as true/false

Hex String Conversions

Certain fields are converted to hex strings for JSON serialization:

encryption_nonce Conversion

The 12-byte nonce is converted to an integer:

Then included as a numeric value in the message.

Use Cases

External Wallet Integration

Hardware Wallet Signing

Testing and Debugging

Notes

  • Used for integration with external signers

  • The hash computed from this data matches eip712_signing_hash(tx)

  • JSON-serializable (no Python-specific types)

  • Follows eth_signTypedData_v4 specification

Warnings

  • to field handling - If tx.to is None, it's encoded as the zero address

  • Hex encoding - All bytes fields must be "0x" prefixed hex strings

  • Integer sizes - Ensure values fit in declared types (e.g., uint64)

See Also

Last updated