Skip to Content
ClientsAsync Client

AsyncClient

AsyncClient is the asynchronous counterpart to Client. The public RPC surface and response modes match the synchronous client; each network method is awaited.

class AsyncClient: def __init__( self, endpoint: str, local: bool = False, clean_response: bool = True, timeout: float = 30.0, http_client: httpx.AsyncClient | None = None, ): ...

Use async with to close Solathon’s connection pool deterministically:

import asyncio from solathon import AsyncClient, PublicKey async def main() -> None: address = PublicKey("B3BhJ1nvPvEhx3hq3nfK8hx4WYcKZdbhavSobZEA44ai") async with AsyncClient("https://api.mainnet-beta.solana.com") as client: balance = await client.get_balance(address, commitment="confirmed") print(balance) asyncio.run(main())

Parallel independent requests

Use asyncio.gather when calls are independent:

async with AsyncClient(endpoint) as client: balance, slot = await asyncio.gather( client.get_balance(address), client.get_slot(commitment="confirmed"), )

JSON-RPC batch requests

Use send_batch when the RPC provider supports JSON-RPC batches and one HTTP round trip is preferable:

async with AsyncClient(endpoint) as client: balance, slot = await client.send_batch( [ ("getBalance", [str(address)]), ("getSlot", [{"commitment": "confirmed"}]), ] )

Send and confirm

async with AsyncClient(endpoint) as client: signature = await client.send_and_confirm_transaction( transaction, commitment="confirmed", poll_interval=0.5, )

If the transaction already contains a recent blockhash, pass its matching last_valid_block_height. For a durable-nonce transaction, provide a finite timeout instead.

See the Client documentation for the full method catalog and the canonical Solana HTTP RPC reference  for wire-level configuration details.