AsyncShieldedContract
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
w3
AsyncWeb3
Yes
Asynchronous AsyncWeb3 instance connected to Seismic RPC
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)
Positional Arguments: *args - ABI function arguments (e.g. await contract.write.transfer(to, amount))
Optional Parameters:
value: int- Wei to send (default:0)gas: int | None- Gas limit (default:30_000_000when omitted)gas_price: int | None- Gas price in wei (default: network suggested)security: [SeismicSecurityParams](../api-reference/transaction-types/seismic-security-params.md) | None- Security parameters for expiry
.read - Encrypted Read
Executes encrypted signed eth_call with encrypted calldata. Result is decrypted and ABI-decoded by the SDK. Single-output functions return the value directly (e.g. int, bool); multi-output functions return a tuple.
Returns: Coroutine[Any] (ABI-decoded Python value)
Positional Arguments: *args - ABI function arguments (e.g. await contract.read.balanceOf(owner))
Optional Parameters:
value: int- Wei for call context (default:0)gas: int- Gas limit (default:30_000_000)security: [SeismicSecurityParams](../api-reference/transaction-types/seismic-security-params.md) | None- Security parameters for expiry
.twrite - Transparent Write
Sends standard async eth_sendTransaction with unencrypted calldata.
Returns: Coroutine[HexBytes] (transaction hash)
Positional Arguments: *args - ABI function arguments
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. Result is ABI-decoded by the SDK. Single-output functions return the value directly; multi-output functions return a tuple.
Returns: Coroutine[Any] (ABI-decoded Python value)
Positional Arguments: *args - ABI function arguments
.dwrite - Debug Write
Like .write but returns debug information including plaintext and encrypted views. Transaction is actually broadcast.
Returns: Coroutine[DebugWriteResult] (DebugWriteResult)
Positional Arguments: *args - ABI function arguments
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
awaitwith every namespace callConcurrent operations: Use
asyncio.gather()for parallel reads/writesDynamic method access: Contract methods resolved via
__getattr__at runtimeABI remapping: Shielded types automatically remapped (same as sync version)
Connection pooling: AsyncWeb3 can reuse connections for better performance
Gas defaults:
.writeuses30_000_000whengasis omitted;.twritefollows normalweb3.py/provider transaction behaviorEIP-712 vs raw: Same signing options as sync version
Error handling: Use try/except around await calls for RPC errors
See Also
ShieldedContract - Synchronous version of this class
AsyncPublicContract - Async read-only contract wrapper
create_async_wallet_client - Create async client
EncryptionState - Manages encryption keys
DebugWriteResult - Debug write return type
SeismicSecurityParams - Transaction expiry parameters
Contract Namespaces - Detailed namespace documentation
Last updated

