file-lockAsyncShieldedContract

Async contract wrapper with shielded and transparent namespaces

Asynchronous contract wrapper providing encrypted and transparent interaction with Seismic contracts.

Overview

AsyncShieldedContract is the async version of ShieldedContract, providing the same five namespaces (.write, .read, .twrite, .tread, .dwrite) but with coroutine-based methods. All namespace methods return coroutines that must be awaited. Use this class in async/await applications for non-blocking contract interactions.

Definition

class AsyncShieldedContract:
    def __init__(
        self,
        w3: AsyncWeb3,
        encryption: EncryptionState,
        private_key: PrivateKey,
        address: ChecksumAddress,
        abi: list[dict[str, Any]],
        eip712: bool = False,
    ) -> None:
        ...

Constructor Parameters

Parameter
Type
Required
Description

w3

AsyncWeb3

Yes

Asynchronous AsyncWeb3 instance connected to Seismic RPC

encryption

Yes

Encryption state for shielded operations

private_key

Yes

32-byte secp256k1 private key for signing transactions

address

ChecksumAddress

Yes

Contract address (checksummed Ethereum address)

abi

list[dict[str, Any]]

Yes

Contract ABI (list of function entries)

eip712

bool

No

Use EIP-712 typed data signing (default: False)

Namespaces

.write - Encrypted Write

Sends encrypted transactions using TxSeismic (type 0x4a). Calldata is encrypted before broadcast.

Returns: Coroutine[HexBytes] (transaction hash)

Optional Parameters:

  • value: int - Wei to send (default: 0)

  • gas: int | None - Gas limit (default: estimated)

  • gas_price: int | None - Gas price in wei (default: network suggested)

  • security: SeismicSecurityParams | None - Security parameters for expiry

.read - Encrypted Read

Executes encrypted signed eth_call with encrypted calldata. Result is decrypted by the SDK.

Returns: Coroutine[HexBytes] (decrypted result bytes)

Optional Parameters:

  • value: int - Wei for call context (default: 0)

  • gas: int - Gas limit (default: 30_000_000)

  • security: SeismicSecurityParams | None - Security parameters for expiry

.twrite - Transparent Write

Sends standard async eth_sendTransaction with unencrypted calldata.

Returns: Coroutine[HexBytes] (transaction hash)

Optional Parameters:

  • value: int - Wei to send (default: 0)

  • **tx_params: Any - Additional transaction parameters (gas, gasPrice, etc.)

.tread - Transparent Read

Executes standard async eth_call with unencrypted calldata.

Returns: Coroutine[HexBytes] (raw result bytes)

Optional Parameters: None (pass positional arguments only)

.dwrite - Debug Write

Like .write but returns debug information including plaintext and encrypted views. Transaction is actually broadcast.

Returns: Coroutine[DebugWriteResult] (DebugWriteResult)

Optional Parameters: Same as .write

Examples

Basic Encrypted Write

Encrypted Read

Transparent Operations

Debug Write

Concurrent Operations

With Transaction Parameters

Batch Processing

Using EIP-712 Signing

Instantiation via Async Client

Error Handling

Context Manager Pattern

Notes

  • All methods return coroutines: Must use await with every namespace call

  • Concurrent operations: Use asyncio.gather() for parallel reads/writes

  • Dynamic method access: Contract methods resolved via __getattr__ at runtime

  • ABI remapping: Shielded types automatically remapped (same as sync version)

  • Connection pooling: AsyncWeb3 can reuse connections for better performance

  • Gas estimation: Happens asynchronously if not provided

  • EIP-712 vs raw: Same signing options as sync version

  • Error handling: Use try/except around await calls for RPC errors

See Also

Last updated