Async Patterns
Concurrent operations and async best practices
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
asyncio.gatherContext manager for cleanup
WebSocket connection
See Also
Last updated

