book-openAsyncSeismicPublicNamespace

AsyncSeismicPublicNamespace class - Read-only public operations (async)

The AsyncSeismicPublicNamespace class provides read-only Seismic functionality for asynchronous public clients. It does not require a private key and is designed for querying blockchain state without performing transactions.

Overview

This namespace is automatically attached as w3.seismic when you create an async public client with create_async_public_client(). It provides:

  • TEE public key retrieval (async)

  • Deposit contract queries (root, count, async)

  • Async public contract wrappers with transparent read capabilities

  • No transaction signing or encryption capabilities

Access

from seismic_web3 import create_async_public_client

public = create_async_public_client("https://gcp-1.seismictest.net/rpc")

# Access the namespace (all methods are async)
await public.seismic.get_tee_public_key()
contract = public.seismic.contract(address, abi)

Public vs Wallet Namespaces

Feature
Public Namespace
Wallet Namespace

Read-only queries

✅ Yes

✅ Yes (inherited)

Shielded writes

❌ No

✅ Yes

Signed reads

❌ No

✅ Yes

Validator deposits

❌ No

✅ Yes

Contract writes

❌ No

✅ Yes

Requires private key

❌ No

✅ Yes

The public namespace is ideal for:

  • Monitoring blockchain state asynchronously

  • Reading public contract data with async/await

  • Querying deposit information concurrently

  • High-performance applications that don't need to send transactions

For write operations, use AsyncSeismicNamespace with an async wallet client.

Class Definition

Methods

Query Methods

get_tee_public_key()

Fetch the TEE's compressed secp256k1 public key (async).

Returns: 33-byte compressed public key (bytes)

Use case: Required for client-side encryption before sending shielded transactions (though this namespace cannot send transactions itself).

See detailed documentation →


get_deposit_root()

Read the current deposit Merkle root from the deposit contract (async).

Parameters:

  • address (str, optional): Deposit contract address (defaults to genesis contract at 0x4242424242424242424242424242424242424242)

Returns: 32-byte deposit root hash

Use case: Verify deposit inclusion or monitor deposit tree state.

See detailed documentation →


get_deposit_count()

Read the current deposit count from the deposit contract (async).

Parameters:

  • address (str, optional): Deposit contract address (defaults to genesis contract at 0x4242424242424242424242424242424242424242)

Returns: Number of deposits as a Python int

Use case: Monitor validator deposits or calculate deposit tree depth.

See detailed documentation →


Contract Factory

contract()

Create an AsyncPublicContract wrapper with transparent read-only capabilities.

Parameters:

  • address (ChecksumAddress): Contract address

  • abi (list[dict[str, Any]]): Contract ABI (list of function entries)

Returns: AsyncPublicContract instance with namespace:

  • .tread - Transparent reads (unencrypted, read-only, async)

Note: This returns an AsyncPublicContract, not an AsyncShieldedContract. It only supports transparent reads via the .tread namespace. For full contract capabilities including writes and encrypted operations, use an async wallet client with AsyncSeismicNamespace.

See contract documentation →


Usage Examples

Basic Query Operations

Concurrent Query Operations

Reading Contract Data

Concurrent Contract Reads

Monitoring Deposits

Multiple Networks Monitoring

Context Manager Pattern

Data Aggregation

Custom Deposit Contract

Async Best Practices

Use asyncio.gather() for Parallel Operations

Handle Connection Cleanup

Error Handling with Async

Batch Operations

When to Use Public vs Wallet Client

Use Async Public Client When:

  1. Read-only operations: You only need to query blockchain state

  2. No private key: You don't have or want to handle private keys

  3. High performance: Need concurrent query execution

  4. Monitoring: Building async monitoring or analytics tools

  5. Public data: Accessing transparent contract data

  6. Security: Minimizing attack surface by not handling keys

Use Async Wallet Client When:

  1. Transactions: You need to send transactions

  2. Shielded operations: Working with encrypted contract calls

  3. Signed reads: Performing authenticated queries

  4. Deposits: Submitting validator deposits

  5. Full contract interaction: Using write operations

Limitations

The async public namespace does not support:

  • Sending transactions (use AsyncSeismicNamespace.send_shielded_transaction())

  • Signed reads (use AsyncSeismicNamespace.signed_call())

  • Shielded contract writes (use AsyncShieldedContract.write)

  • Debug transactions (use AsyncSeismicNamespace.debug_send_shielded_transaction())

  • Validator deposits (use AsyncSeismicNamespace.deposit())

Attempting to perform these operations requires upgrading to an async wallet client:

Performance Considerations

Connection Pooling

Concurrent Limits

See Also

Last updated