Skip to main content

getTokenAccountsByDelegate

Retrieves all SPL token accounts for which a specified delegate has been approved.

Parameters

  • address: (string) [required] - The base58 encoded public key of the delegate account to query.
  • accountDetails: (object) [required] - An object containing one the following fields:
    • mint: (string) [optional] - The base58 encoded public key of the mint account.
    • programId: (string) [optional] - The base58 encoded public key of the token program that owns the account.
  • config: (object) [optional] - Configuration object with the following options:
    • commitment: (string) [optional] - The commitment level to use for the query. The default is finalized. Possible values are:
      • finalized - Queries the most recent block confirmed by a super majority of the cluster as having reached maximum lockout, meaning the cluster has recognized this block as finalized.
      • confirmed - Queries the most recent block that has been voted on by a super majority of the cluster.
      • processed - Queries its most recent block. The block may still be skipped by the cluster.
    • encoding: (string) [optional] - The encoding format to use. Can be one of base58, base64, base64+zstd, or jsonParsed
    • dataSlice: (object) [optional] - A slice of the account data to return. Only available for base58, base64, or base64+zstd encoding. This is an object with two properties:
      • offset - The starting byte offset of the slice.
      • length - The length of the slice in bytes.
    • minContextSlot: [optional] - The minimum slot to use for the query.

Returns

result - An array of objects with the following fields:

  • context - An object containing the following keys:
    • slot - The slot number of the block that was queried.
    • apiVersion - The API version used for the query.
  • value - An object with the following fields:
    • pubkey - The base58 encoded public key of the token account.
    • account - An object containing the address used to store assets:
      • data - An object containing token state data associated with the account, either as encoded binary data or in JSON format:
        • program The program that manages the token.
        • parsed - An array of parsed instructions that were executed in the block's transactions:
          • info - An array of objects that provide additional details about the transactions in the block:
            • tokenAmount - The balance of the token in the token account.
              • amount - The raw total token supply without decimals, a string representation of a u64 integer.
              • decimals - An integer value representing the number of decimal places used by the token.
              • uiAmount - The total token supply using mint-prescribed decimals (DEPRECATED).
              • uiAmountString - The total token supply as a string using mint-prescribed decimals.
            • isNative - A boolean value indicating whether the token is a native token of the Solana blockchain.
            • mint - Provides information about the creation of new tokens.
            • owner - The base-58 encoded Pubkey of the program this account has been assigned to.
            • state - The current state of the token account.
          • type - The type of the block. It can be used to differentiate between regular blocks and special blocks such as snapshot or transaction confirmation blocks.
        • space - The amount of storage space required to store the token account.
      • executable - A boolean indicating whether the account is executable.
      • lamports - The number of lamports in the account.
      • owner - The public key of the program that owns the account.
      • rentEpoch - The epoch in which the account will next be due for rent.
      • space - The size of the account data in bytes.

Example

Replace <YOUR-API-KEY> with your API key.

Request

curl https://solana-mainnet.infura.io/v3/<YOUR-API-KEY> \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "id": 1, "method": "getTokenAccountsByDelegate", "params": ["4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T", {"programId":"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"}, {"encoding": "jsonParsed"}]}'

Response

{
"jsonrpc": "2.0",
"result": {
"context": { "slot": 1114 },
"value": [
{
"pubkey": "28YTZEwqtMHWrhWcvv34se7pjS7wctgqzCPB3gReCFKp",
"account": {
"data": {
"program": "spl-token",
"parsed": {
"info": {
"tokenAmount": {
"amount": "1",
"decimals": 1,
"uiAmount": 0.1,
"uiAmountString": "0.1"
},
"delegate": "4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T",
"delegatedAmount": {
"amount": "1",
"decimals": 1,
"uiAmount": 0.1,
"uiAmountString": "0.1"
},
"state": "initialized",
"isNative": false,
"mint": "3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E",
"owner": "CnPoSPKXu7wJqxe59Fs72tkBeALovhsCxYeFwPCQH9TD"
},
"type": "account"
},
"space": 165
},
"executable": false,
"lamports": 1726080,
"owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"rentEpoch": 4,
"space": 165
}
}
]
},
"id": 1
}