gearChainConfig

Immutable network configuration dataclass

Immutable configuration for a Seismic network, including RPC endpoints, chain ID, and client factory methods.

Overview

ChainConfig is a frozen dataclass that encapsulates all information needed to connect to a Seismic network. Instead of passing RPC URLs and chain IDs separately, you create a ChainConfig once and use its convenience methods to create clients.

Definition

@dataclass(frozen=True)
class ChainConfig:
    """Immutable configuration for a Seismic network.

    Attributes:
        chain_id: Numeric chain identifier.
        rpc_url: HTTP(S) JSON-RPC endpoint.
        ws_url: WebSocket endpoint (``None`` if not available).
        name: Human-readable network name.
    """
    chain_id: int
    rpc_url: str
    ws_url: str | None = None
    name: str = ""

Attributes

Attribute
Type
Required
Description

chain_id

int

Yes

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

rpc_url

str

Yes

HTTP(S) JSON-RPC endpoint

ws_url

str | None

No

WebSocket endpoint (default: None)

name

str

No

Human-readable network name (default: "")

Construction

Basic Usage

Without WebSocket

Using Pre-Defined Configs

Methods

wallet_client()

Create a synchronous Web3 instance with wallet capabilities.

Parameters

Parameter
Type
Required
Description

private_key

PrivateKey

Yes

32-byte signing key for transactions

encryption_sk

PrivateKey | None

No

Optional 32-byte key for ECDH

Returns

  • Web3 - A synchronous Web3 instance with w3.seismic namespace attached

Example


async_wallet_client()

Create an asynchronous Web3 instance with wallet capabilities.

Parameters

Parameter
Type
Required
Description

private_key

PrivateKey

Yes

32-byte signing key for transactions

encryption_sk

PrivateKey | None

No

Optional 32-byte key for ECDH

ws

bool

No

If True, uses WebSocketProvider (default: False)

Returns

  • AsyncWeb3 - An asynchronous Web3 instance with w3.seismic namespace attached

Behavior

  • When ws=True and ws_url is set, the WebSocket URL is used automatically

  • When ws=False, the HTTP rpc_url is used

  • Raises ValueError if ws=True but ws_url is None

Example


public_client()

Create a synchronous Web3 instance with public (read-only) access.

Parameters

None. (public clients don't handle private keys)

Returns

  • Web3 - A synchronous Web3 instance with w3.seismic namespace attached (read-only)

Example


async_public_client()

Create an asynchronous Web3 instance with public (read-only) access.

Parameters

Parameter
Type
Required
Description

ws

bool

No

If True, uses WebSocketProvider (default: False)

Returns

  • AsyncWeb3 - An asynchronous Web3 instance with w3.seismic namespace attached (read-only)

Example

Deprecated Methods

create_client()

Deprecated: use wallet_client() instead.

create_async_client()

Deprecated: use async_wallet_client() instead.

Notes

  • All client creation methods return standard web3.py instances

  • The w3.seismic namespace is automatically attached to all clients

  • WebSocket connections provide better performance for subscription-based workflows

  • HTTP connections are suitable for simple request-response patterns

See Also

Last updated