walletBasic Wallet Setup

Complete wallet client setup with both sync and async variants

This example demonstrates how to set up Seismic wallet clients in both synchronous and asynchronous variants. A wallet client provides full capabilities including shielded writes, signed reads, and deposits.

Prerequisites

# Install the SDK
pip install seismic-web3

# Set your private key (32 bytes hex, without 0x prefix)
export PRIVATE_KEY="your_64_char_hex_private_key"

Synchronous Wallet Client

The sync client is simpler and suitable for scripts, CLI tools, and applications that don't need concurrent operations.

import os
from seismic_web3 import create_wallet_client, PrivateKey, SEISMIC_TESTNET

# Load private key from environment
private_key = PrivateKey.from_hex_str(os.environ["PRIVATE_KEY"])

# Method 1: Using chain config (recommended)
w3 = SEISMIC_TESTNET.wallet_client(private_key)

# Method 2: Using RPC URL directly
# w3 = create_wallet_client(
#     "https://gcp-1.seismictest.net/rpc",
#     private_key=private_key,
# )

# Verify connection
print(f"Connected to chain ID: {w3.eth.chain_id}")
print(f"Current block number: {w3.eth.block_number}")
print(f"Your address: {w3.eth.default_account}")

# Get TEE public key (required for encryption)
tee_pubkey = w3.seismic.get_tee_public_key()
print(f"TEE public key: {tee_pubkey.to_0x_hex()}")

# Check your balance
balance = w3.eth.get_balance(w3.eth.default_account)
print(f"Balance: {w3.from_wei(balance, 'ether')} ETH")

Asynchronous Wallet Client

The async client enables concurrent operations, WebSocket connections, and is ideal for high-performance applications.

Custom Encryption Key

By default, a random ephemeral encryption key is generated. You can provide a deterministic key for reproducibility:

Error Handling

Expected Output

Common Variations

Using SANVIL Testnet

Multiple Clients (Multi-Account)

Connection Verification

Next Steps

See Also

Last updated