getTokenAccountsByOwner
Returns all SPL Token accounts by token owner.
This method will use 30 Compute Units.
getTokenAccountsByOwner for Solana is limited to 200 requests per second. If you have higher rate limit needs, contact us.
Parameters
pubkeystring. The Pubkey of account delegate to query encoded as base-58 string.objectarray. The JSON object with the following fields:mintstring. The Pubkey of the specific token Mint to limit accounts to, as base-58 encoded string.programIdstring. The Pubkey of the Token program ID that owns the accounts, as base-58 encoded string.
objectoptional. Configuration object containing the following fields:commitmentstring. The level of commitment required for the query. The options include:finalizedstring. The node will query the most recent block confirmed by the supermajority of the cluster as having reached maximum lockout, meaning the cluster has recognized this block as finalized.confirmedstring. The node will query the most recent block that has been voted on by the supermajority of the cluster.processedstring. The node will query its most recent block. Note that the block may not be complete.
encodingstring. The encoding format for account data. It can be one of base58 (slow, base64, base64+zstd or jsonParsed.dataSlicestring The returned account data using the provided offset: 'usize' and length: 'usize' fields; only available for base58, base64, or base64+zstd encodings.minContextSlotinteger The minimum slot at which the request can be evaluated.
Returns
result An object with the following fields:
contextThe information about the current state of the program.apiVersionThe version of the Solana RPC API to use.slotAn integer representing the slot for which to retrieve the fee calculator.
valueA JSON object with the following fields:accountAn address on the Solana blockchain that is used to store assets.dataA string containing the encoded data to be passed to the instruction.parsedAn array of parsed instructions that were executed in the block's transactions.infoAn array of information objects that provide additional details about the transactions in the block.isNativeA boolean value indicating whether the token is a native token of the Solana blockchain.mintProvides information about the creation of new tokens.ownerThe base-58 encoded Pubkey of the program this account has been assigned to.stateThe current state of the token account.tokenAmountThe balance of the token in the token account.amountThe raw total token supply without decimals, a string representation of a u64 integer.decimalsAn integer value representing the number of decimal places used by the token.uiAmountThe total token supply using mint-prescribed decimals (DEPRECATED).uiAmountStringThe total token supply as a string using mint-prescribed decimals.
typeThe type of the block. It can be used to differentiate between regular blocks and special blocks such as snapshot or transaction confirmation blocks.
programThe program that manages the token.spaceThe amount of storage space required to store the token account.
executableA boolean indicating if the account contains a program (and is strictly read-only).lamportsThe number of lamports assigned to this account as u64 (64-bit unsigned integer).ownerThe base-58 encoded Pubkey of the program this account has been assigned to.rentEpochThe epoch at which the token account's storage will be subject to rent.spaceThe amount of storage space required to store the token account.
pubkeyThe public key associated with the token account.
// Result
{
"jsonrpc": "2.0",
"result": {
"context": {
"apiVersion": "2.1.11",
"slot": 320380251
},
"value": [
{
"account": {
"data": {
"parsed": {
"info": {
"isNative": false,
"mint": "1YDQ35V8g68FGvcT85haHwAXv1U7XMzuc4mZeEXfrjE",
"owner": "GgPpTKg78vmzgDtP1DNn72CHAYjRdKY7AV6zgszoHCSa",
"state": "initialized",
"tokenAmount": {
"amount": "5",
"decimals": 0,
"uiAmount": 5.0,
"uiAmountString": "5"
}
},
"type": "account"
},
"program": "spl-token",
"space": 165
},
"executable": false,
"lamports": 2039280,
"owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"rentEpoch": 18446744073709551615,
"space": 165
},
"pubkey": "9duBrvbQPiNng7ggy58pVhV8RieLZnyD6TuKCMhcqzjp"
}
]
},
"id": 1
}curl https://mainnet.solana.validationcloud.io/v1/<YOUR_API_KEY_HERE> \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0","id": 1,"method": "getTokenAccountsByOwner","params": ["GgPpTKg78vmzgDtP1DNn72CHAYjRdKY7AV6zgszoHCSa",{"mint": "1YDQ35V8g68FGvcT85haHwAXv1U7XMzuc4mZeEXfrjE"},{"encoding": "jsonParsed"}]}'
curl https://devnet.solana.validationcloud.io/v1/<YOUR_API_KEY_HERE> \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0","id": 1,"method": "getTokenAccountsByOwner","params": ["GgPpTKg78vmzgDtP1DNn72CHAYjRdKY7AV6zgszoHCSa",{"mint": "1YDQ35V8g68FGvcT85haHwAXv1U7XMzuc4mZeEXfrjE"},{"encoding": "jsonParsed"}]}'
Last updated
Was this helpful?