getTokenAccountsByOwner | Solana

Solana getTokenAccountsByOwner Method

The Solana getTokenAccountsByOwner method retrieves a list of accounts owned by a specified wallet, filtered by their associated token.

This method is useful for identifying all accounts associated with a particular owner and a specific token, allowing for a comprehensive view of token distribution and ownership.

πŸ“˜

The interactive example fetches the GME tokens owned by an account on Solana mainnet.

πŸ‘

Get you own node endpoint today

Start for free and get your app to production levels immediately. No credit card required.

You can sign up with your GitHub, X, Google, or Microsoft account.

Parameters

  • delegatePubkey β€” the base-58 encoded string representing the public key of the account delegate to query.
  • filters β€” a JSON object with one of the following fields:
    • mint β€” the base-58 encoded string of the specific token Mint to limit accounts to.
    • programId β€” the base-58 encoded string of the Token program that owns the accounts.
  • config (optional) β€” configuration object containing the following fields:
    • commitment (optional) β€” the level of commitment desired for the query.
    • minContextSlot (optional) β€” te minimum slot that the request can be evaluated at.
    • dataSlice (optional) β€” request a slice of the account's data, specifying length (number of bytes to return) and offset (byte offset from which to start reading).
    • encoding (optional) β€” the format of the returned account data. Possible values are base58, base64, base64+zstd, or jsonParsed.

Response

  • value β€” an array of JSON objects, each containing:
    • pubkey β€” the account Pubkey as a base-58 encoded string.
    • accountβ€” a JSON object with subfields:
      • lamports β€” number of lamports assigned to this account, as a u64.
      • owner β€” base-58 encoded Pubkey of the program to which this account has been assigned.
      • data β€” token state data associated with the account as encoded binary data or in JSON format.
      • executable β€” boolean indicating if the account contains a program (and is strictly read-only).
      • rentEpoch β€” the epoch at which this account will next owe rent, as a u64.
      • size β€” the data size of the account.

Use Case

A practical use case for getTokenAccountsByOwner is for wallet interfaces or financial tracking applications to list all accounts associated with a particular owner and token type. This can be especially useful for assessing the distribution of tokens across different accounts and for transaction history analysis.

Try the getTokenAccountsByOwner RPC Method Yourself

Language
Click Try It! to start a request and see the response here!