ChainConfig
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
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
private_key
PrivateKey
Yes
32-byte signing key for transactions
encryption_sk
PrivateKey | None
No
Optional 32-byte key for ECDH
Returns
Web3- A synchronousWeb3instance withw3.seismicnamespace attached
Example
async_wallet_client()
Create an asynchronous Web3 instance with wallet capabilities.
Parameters
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 asynchronousWeb3instance withw3.seismicnamespace attached
Behavior
When
ws=Trueandws_urlis set, the WebSocket URL is used automaticallyWhen
ws=False, the HTTPrpc_urlis usedRaises
ValueErrorifws=Truebutws_urlisNone
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 synchronousWeb3instance withw3.seismicnamespace attached (read-only)
Example
async_public_client()
Create an asynchronous Web3 instance with public (read-only) access.
Parameters
ws
bool
No
If True, uses WebSocketProvider (default: False)
Returns
AsyncWeb3- An asynchronousWeb3instance withw3.seismicnamespace 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.pyinstancesThe
w3.seismicnamespace is automatically attached to all clientsWebSocket connections provide better performance for subscription-based workflows
HTTP connections are suitable for simple request-response patterns
See Also
SEISMIC_TESTNET - Pre-defined testnet configuration
SANVIL - Pre-defined local development configuration
make_seismic_testnet - Factory for testnet instances
create_wallet_client - Direct wallet client creation
create_public_client - Direct public client creation
PrivateKey - Private key type
Last updated

