arrows-spincreate_async_wallet_client

Create async Web3 instance with full Seismic wallet capabilities

Create an asynchronous AsyncWeb3 instance with full Seismic wallet capabilities.

Overview

create_async_wallet_client() is the async factory function for creating a client that can perform shielded writes, signed reads, and deposits. It supports both HTTP and WebSocket connections, fetches the TEE public key asynchronously, derives encryption state via ECDHarrow-up-right, and attaches a fully-configured w3.seismic namespace.

The returned client works with all standard async web3.py APIs (await w3.eth.get_block(), etc.) plus the additional w3.seismic namespace for Seismic-specific operations.

Signature

async def create_async_wallet_client(
    provider_url: str,
    private_key: PrivateKey,
    *,
    encryption_sk: PrivateKey | None = None,
    ws: bool = False,
) -> AsyncWeb3

Parameters

Parameter
Type
Required
Description

provider_url

str

Yes

HTTP(S) or WS(S) URL of the Seismic node

private_key

Yes

32-byte secp256k1 private key for signing transactions

encryption_sk

No

Optional 32-byte key for ECDH. If None, a random ephemeral key is generated

ws

bool

No

If True, uses WebSocketProvider (persistent connection, supports subscriptions). Otherwise uses AsyncHTTPProvider. Default: False. WebSocket is only available on async clients — sync clients are HTTP-only

Returns

Type
Description

AsyncWeb3

An AsyncWeb3 instance with w3.seismic namespace attached (AsyncSeismicNamespace)

Examples

Basic Usage (HTTP)

WebSocket Connection

Using Chain Configuration

Context Manager Pattern

Async Application

With Custom Encryption Key

How It Works

The function performs six steps:

  1. Create provider

  2. Create AsyncWeb3 instance

  3. Fetch TEE public key (async RPC call)

  4. Generate encryption keypair (if encryption_sk is None, a random ephemeral key is created)

  5. Derive encryption state (ECDH + HKDFarrow-up-right)

  6. Attach Seismic namespace

Client Capabilities

The returned client provides:

Standard AsyncWeb3 Methods (e.g. w3.eth, w3.net)

  • await get_block(), await get_transaction(), await get_balance()

  • await send_raw_transaction(), await wait_for_transaction_receipt()

  • All other standard async web3.py functionality

Async Seismic Methods (w3.seismic)

HTTP vs WebSocket

Aspect

AsyncHTTPProvider (ws=False)

WebSocketProvider (ws=True)

Connection

New connection per request

Persistent connection

Latency

Higher per-request overhead

Lower latency

Subscriptions

Not supported

Supported (eth.subscribe)

Resource usage

Lower idle usage

Keeps connection open

Use case

One-off transactions

Real-time monitoring, subscriptions

Encryption

The client automatically:

  • Fetches the network's TEE public key asynchronously

  • Performs ECDH key exchange using encryption_sk (or generates a random one)

  • Derives a shared AES-GCM key via HKDF

  • Uses this key to encrypt all shielded transaction calldata and signed reads

Access the encryption state at w3.seismic.encryption if needed for advanced use cases.

Notes

  • The function is async and must be await-ed

  • Makes one asynchronous RPC call to fetch the TEE public key

  • If encryption_sk is None, a random ephemeral key is generated

  • The encryption key is separate from the transaction signing key

  • WebSocket connections should be properly closed when done

  • All w3.seismic methods are async and must be await-ed

  • For sync operations, use create_wallet_client()

Warnings

  • Private key security - Never log or expose private keys. Use environment variables or secure key management

  • Connection cleanup - Close WebSocket connections properly to avoid resource leaks

  • Error handling - WebSocket connections can drop; implement reconnection logic for production

  • HTTPS/WSS recommended - Use secure protocols in production to prevent MITM attacks

See Also

Last updated