Async Patterns
Concurrent operations and async best practices
The async client mirrors the sync API but requires await on all operations.
Setup
import asyncio
import os
from seismic_web3 import PrivateKey, SEISMIC_TESTNET
pk = PrivateKey.from_hex_str(os.environ["PRIVATE_KEY"])
async def main():
w3 = await SEISMIC_TESTNET.async_wallet_client(pk)
try:
chain_id = await w3.eth.chain_id
block = await w3.eth.block_number
print(f"Chain {chain_id}, block {block}")
finally:
await w3.provider.disconnect()
asyncio.run(main())Concurrent reads with asyncio.gather
Context manager for cleanup
WebSocket connection
Use ws=True for event streaming:
See Also
create_async_wallet_client — Async client API reference
AsyncShieldedContract — Async contract wrapper
Event Watching — Decrypt SRC20 events
Last updated

