Skip to main content

Module client

Module client 

Source
Available on crate feature client only.
Expand description

Async RPC helpers for fetching and deserializing on-chain accounts.

Enable with the client feature:

[dependencies]
anchor-parser = { version = "0.1.3", features = ["client"] }

§Example

use anchor_parser::client;
use my_program::accounts::MyAccount;

let account = client::fetch_account::<MyAccount>(&rpc, &address).await?;
let accounts = client::fetch_accounts::<MyAccount>(&rpc, &[a1, a2]).await?;

Async RPC client helpers for fetching and deserializing on-chain accounts.

This module is available when the client feature is enabled, which adds a dependency on solana-client.

[dependencies]
anchor-parser = { version = "0.1.3", features = ["client"] }

§Examples

use anchor_parser::client;
use my_program::accounts::MyAccount;

let rpc = solana_client::nonblocking::rpc_client::RpcClient::new("https://api.mainnet-beta.solana.com".to_string());

// Fetch a single account
let account = client::fetch_account::<MyAccount>(&rpc, &address).await?;

// Fetch multiple accounts at once
let accounts = client::fetch_accounts::<MyAccount>(&rpc, &[addr1, addr2]).await?;

Functions§

fetch_account
Fetch a single account and deserialize it into type T.
fetch_accounts
Fetch multiple accounts of the same type in a single RPC call.