Skip to main content

getTokenAccountsByOwner RPC Method

Returns all SPL Token accounts by token owner.

Parameters

string required
Pubkey of account owner to query
  • Base-58 encoded string
object required
A JSON object with one of the following fields:
  • mint: <string> - Pubkey of the specific token Mint
    • Base-58 encoded string
  • programId: <string> - Pubkey of the Token program that owns the accounts
    • Base-58 encoded string
object optional
Configuration object containing the following fields:
commitment string optional
The level of commitment desired when querying state
minContextSlot number optional
The minimum slot that the request can be evaluated at
dataSlice object optional
Request a slice of the account’s data
  • length: <usize> - number of bytes to return
  • offset: <usize> - byte offset from which to start reading
encoding string optional
Encoding format for Account data
  • Default: not specified
Allowed Encoding Values:
  • base58
  • base64
  • base64+zstd
  • jsonParsed

Data Slicing Note

Data slicing is only available for base58, base64, or base64+zstd encodings.

Code Sample

Response

Result Details

The result is an RpcResponse JSON object with value as an array of account objects:
  • pubkey: <string>
    • Account Pubkey as a base-58 encoded string
    • Uniquely identifies the token account
  • account: <object>
    • Detailed account information:
      • lamports: <u64> - Number of lamports in the account
      • owner: <string> - Pubkey of the program owning the account
      • data: <object> - Token state data
      • executable: <bool> - Indicates if the account contains a program
      • rentEpoch: <u64> - Epoch when rent is next due
      • space: <u64> - Size of the account data

Additional Notes

  • When using jsonParsed encoding, expect a Token Balances Structure
  • tokenAmount provides detailed token balance information
  • Optional delegatedAmount may be present in the parsed data