Struct AccountsScanClient

Source
pub struct AccountsScanClient { /* private fields */ }
Expand description

The Client.

Implementations§

Source§

impl Client

Source

pub fn new(sender: RpcChannel) -> Self

Creates a new Client.

Source

pub fn get_program_accounts( &self, program_id_str: String, config: Option<RpcProgramAccountsConfig>, ) -> impl Future<Output = RpcResult<OptionalContext<Vec<RpcKeyedAccount>>>>

Returns all accounts owned by the specified program ID, optionally filtered and configured.

This RPC method retrieves all accounts whose owner is the given program. It is commonly used to scan on-chain program state, such as finding all token accounts, order books, or PDAs owned by a given program. The results can be filtered using data size, memory comparisons, and token-specific criteria.

§Parameters
  • program_id_str: Base-58 encoded program ID to scan for owned accounts.
  • config: Optional configuration object allowing filters, encoding options, context inclusion, and sorting of results.
§Returns

A future resolving to a vector of RpcKeyedAccounts wrapped in an OptionalContext. Each result includes the account’s public key and full account data.

§Example Request (JSON-RPC)
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getProgramAccounts",
  "params": [
    "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
    {
      "filters": [
        {
          "dataSize": 165
        },
        {
          "memcmp": {
            "offset": 0,
            "bytes": "3N5kaPhfUGuTQZPQ3mnDZZGkUZ97rS1NVSC94QkgUzKN"
          }
        }
      ],
      "encoding": "jsonParsed",
      "commitment": "finalized",
      "withContext": true
    }
  ]
}
§Example Response
{
  "jsonrpc": "2.0",
  "result": {
    "context": {
      "slot": 12345678
    },
    "value": [
      {
        "pubkey": "BvckZ2XDJmJLho7LnFnV7zM19fRZqnvfs8Qy3fLo6EEk",
        "account": {
          "lamports": 2039280,
          "data": {...},
          "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
          "executable": false,
          "rentEpoch": 255,
          "space": 165
        }
      },
      ...
    ]
  },
  "id": 1
}
§Filters
  • DataSize(u64): Only include accounts with a matching data length.
  • Memcmp: Match byte patterns at specified offsets in account data.
  • TokenAccountState: Match on internal token account state (e.g. initialized).
§See also
Source

pub fn get_largest_accounts( &self, config: Option<RpcLargestAccountsConfig>, ) -> impl Future<Output = RpcResult<RpcResponse<Vec<RpcAccountBalance>>>>

Returns the 20 largest accounts by lamport balance, optionally filtered by account type.

This RPC endpoint is useful for analytics, network monitoring, or understanding the distribution of large token holders. It can also be used for sanity checks on protocol activity or whale tracking.

§Parameters
  • config: Optional configuration allowing for filtering on specific account types such as circulating or non-circulating accounts.
§Returns

A future resolving to a RpcResponse containing a list of the 20 largest accounts by lamports, each represented as an RpcAccountBalance.

§Example Request (JSON-RPC)
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getLargestAccounts",
  "params": [
    {
      "filter": "circulating"
    }
  ]
}
§Example Response
{
  "jsonrpc": "2.0",
  "result": {
    "context": {
      "slot": 15039284
    },
    "value": [
      {
        "lamports": 999999999999,
        "address": "9xQeWvG816bUx9EPaZzdd5eUjuJcN3TBDZcd8DM33zDf"
      },
      ...
    ]
  },
  "id": 1
}
§See also
§Notes

This method only returns up to 20 accounts and is primarily intended for inspection or diagnostics.

Source

pub fn get_supply( &self, config: Option<RpcSupplyConfig>, ) -> impl Future<Output = RpcResult<RpcResponse<RpcSupply>>>

Returns information about the current token supply on the network, including circulating and non-circulating amounts.

This method provides visibility into the economic state of the chain by exposing the total amount of tokens issued, how much is in circulation, and what is held in non-circulating accounts.

§Parameters
  • config: Optional RpcSupplyConfig that allows specifying commitment level and whether to exclude the list of non-circulating accounts from the response.
§Returns

A future resolving to a RpcResponse containing a RpcSupply struct with supply metrics in lamports.

§Example Request (JSON-RPC)
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getSupply",
  "params": [
    {
      "excludeNonCirculatingAccountsList": true
    }
  ]
}
§Example Response
{
  "jsonrpc": "2.0",
  "result": {
    "context": {
      "slot": 18000345
    },
    "value": {
      "total": 510000000000000000,
      "circulating": 420000000000000000,
      "nonCirculating": 90000000000000000,
      "nonCirculatingAccounts": []
    }
  },
  "id": 1
}
§See also
  • RpcSupplyConfig: Configuration struct for optional parameters.
  • RpcSupply: Response struct with total, circulating, and non-circulating amounts.
§Notes
  • All values are returned in lamports.
  • Use this method to monitor token inflation, distribution, and locked supply dynamics.
Source

pub fn get_token_largest_accounts( &self, mint_str: String, commitment: Option<CommitmentConfig>, ) -> impl Future<Output = RpcResult<RpcResponse<Vec<RpcTokenAccountBalance>>>>

Returns the addresses and balances of the largest accounts for a given SPL token mint.

This method is useful for analyzing token distribution and concentration, especially to assess decentralization or identify whales.

§Parameters
  • mint_str: The base-58 encoded public key of the mint account of the SPL token.
  • commitment: Optional commitment level to query the state of the ledger at different levels of finality (e.g., Processed, Confirmed, Finalized).
§Returns

A BoxFuture resolving to a RpcResponse with a vector of RpcTokenAccountBalances, representing the largest accounts holding the token.

§Example Request (JSON-RPC)
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getTokenLargestAccounts",
  "params": [
    "So11111111111111111111111111111111111111112"
  ]
}
§Example Response
{
  "jsonrpc": "2.0",
  "result": {
    "context": {
      "slot": 18300000
    },
    "value": [
      {
        "address": "5xy34...Abcd1",
        "amount": "100000000000",
        "decimals": 9,
        "uiAmount": 100.0,
        "uiAmountString": "100.0"
      },
      {
        "address": "2aXyZ...Efgh2",
        "amount": "50000000000",
        "decimals": 9,
        "uiAmount": 50.0,
        "uiAmountString": "50.0"
      }
    ]
  },
  "id": 1
}
§See also
  • [UiTokenAmount]: Describes the token amount in different representations.
  • RpcTokenAccountBalance: Includes token holder address and amount.
§Notes
  • Balances are sorted in descending order.
  • Token decimals are used to format the raw amount into a user-friendly float string.
Source

pub fn get_token_accounts_by_owner( &self, owner_str: String, token_account_filter: RpcTokenAccountsFilter, config: Option<RpcAccountInfoConfig>, ) -> impl Future<Output = RpcResult<RpcResponse<Vec<RpcKeyedAccount>>>>

Returns all SPL Token accounts owned by a specific wallet address, optionally filtered by mint or program.

This endpoint is commonly used by wallets and explorers to retrieve all token balances associated with a user, and optionally narrow results to a specific token mint or program.

§Parameters
  • owner_str: The base-58 encoded public key of the wallet owner.
  • token_account_filter: A RpcTokenAccountsFilter enum that allows filtering results by:
    • Mint address
    • Program ID (usually the SPL Token program)
  • config: Optional configuration for encoding, data slicing, and commitment.
§Returns

A BoxFuture resolving to a RpcResponse containing a vector of RpcKeyedAccounts. Each entry contains the public key of a token account and its deserialized account data.

§Example Request (JSON-RPC)
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getTokenAccountsByOwner",
  "params": [
    "4Nd1mKxQmZj...Aa123",
    {
      "mint": "So11111111111111111111111111111111111111112"
    },
    {
      "encoding": "jsonParsed"
    }
  ]
}
§Example Response
{
  "jsonrpc": "2.0",
  "result": {
    "context": { "slot": 19281234 },
    "value": [
      {
        "pubkey": "2sZp...xyz",
        "account": {
          "lamports": 2039280,
          "data": { /* token info */ },
          "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
          "executable": false,
          "rentEpoch": 123
        }
      }
    ]
  },
  "id": 1
}
§Filter Enum

RpcTokenAccountsFilter can be:

  • Mint(String) — return only token accounts associated with the specified mint.
  • ProgramId(String) — return only token accounts owned by the specified program (e.g. SPL Token program).
§See also
§Notes
  • The response may contain Option::None for accounts that couldn’t be fetched or decoded.
  • Encoding jsonParsed is recommended when integrating with frontend UIs.
Source

pub fn get_token_accounts_by_delegate( &self, delegate_str: String, token_account_filter: RpcTokenAccountsFilter, config: Option<RpcAccountInfoConfig>, ) -> impl Future<Output = RpcResult<RpcResponse<Vec<RpcKeyedAccount>>>>

Returns all SPL Token accounts that have delegated authority to a specific address, with optional filters.

This RPC method is useful for identifying which token accounts have granted delegate rights to a particular wallet or program (commonly used in DeFi apps or custodial flows).

§Parameters
  • delegate_str: The base-58 encoded public key of the delegate authority.
  • token_account_filter: A RpcTokenAccountsFilter enum to filter results by mint or program.
  • config: Optional RpcAccountInfoConfig for controlling account encoding, commitment level, etc.
§Returns

A BoxFuture resolving to a RpcResponse containing a vector of RpcKeyedAccounts, each pairing a token account public key with its associated on-chain data.

§Example Request (JSON-RPC)
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getTokenAccountsByDelegate",
  "params": [
    "3qTwHcdK1j...XYZ",
    { "programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" },
    { "encoding": "jsonParsed" }
  ]
}
§Example Response
{
  "jsonrpc": "2.0",
  "result": {
    "context": { "slot": 19301523 },
    "value": [
      {
        "pubkey": "8H5k...abc",
        "account": {
          "lamports": 2039280,
          "data": { /* token info */ },
          "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
          "executable": false,
          "rentEpoch": 131
        }
      }
    ]
  },
  "id": 1
}
§Filters

Use RpcTokenAccountsFilter to limit the query scope:

  • Mint(String) – return accounts associated with a given token.
  • ProgramId(String) – return accounts under a specific program (e.g., SPL Token program).
§Notes
  • Useful for monitoring delegated token activity in governance or trading protocols.
  • If a token account doesn’t have a delegate, it won’t be included in results.
§See also

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl From<RpcChannel> for Client

Source§

fn from(channel: RpcChannel) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,