Learn getTokenAccountsByDelegate use cases, code examples, request parameters, response structure, and tips.
getTokenAccountsByDelegate
RPC method retrieves all SPL Token accounts that have approved a specific public key as a delegate. A delegate has authority to perform certain actions on the token account, such as transferring or burning tokens, up to the delegated amount.
This method is useful for services that manage delegated authority or need to discover which token accounts a particular key can act on behalf of.
delegatePubkey
(string, required): The base-58 encoded public key of the delegate account whose associated token accounts you want to find.
filter
(object, required): A JSON object that must specify either mint
or programId
to filter the accounts:
mint
(string): The base-58 encoded public key of a specific token mint. If provided, the query will only return token accounts of this particular token type that are delegated to delegatePubkey
.programId
(string): The base-58 encoded public key of the Token Program that owns the accounts. This will typically be the standard SPL Token Program (TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
) or the Token-2022 Program (TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb
).options
(object, optional): An optional configuration object with the following common fields:
commitment
(string, optional): Specifies the commitment level.encoding
(string, optional): The encoding for account data. "jsonParsed"
is highly recommended as it returns human-readable account information. Other options include "base64"
, "base64+zstd"
. Defaults to "base64"
if not specified.dataSlice
(object, optional): Allows you to retrieve only a specific slice of the account data. Contains offset
(usize) and length
(usize) fields. Only applicable for base58
, base64
, or base64+zstd
encodings.minContextSlot
(u64, optional): The minimum slot that the request can be evaluated at.result.value
field in the JSON-RPC response is an array of objects. Each object represents a token account that has delegatePubkey
as its delegate and matches the filter
criteria. Each object in the array has two fields:
pubkey
(string): The base-58 encoded public key of the token account itself.account
(object): An object containing detailed information about the token account:
lamports
(u64): The lamport balance of the token account (for rent exemption).owner
(string): The public key of the program that owns this account (e.g., the Token Program).data
: The account data. If "jsonParsed"
encoding is used, this will be an object with a program
field (e.g., "spl-token"
) and a parsed
field containing structured information:
parsed.info
: An object with details like:
mint
(string): The mint address of the token.owner
(string): The owner of the token account (not the delegate).tokenAmount
(object): The total balance of tokens in this account (amount
, decimals
, uiAmount
, uiAmountString
).delegate
(string): The public key of the delegate (should match the delegatePubkey
from the request).delegatedAmount
(object): The amount of tokens the delegate is authorized to manage (amount
, decimals
, uiAmount
, uiAmountString
).isNative
(boolean): Indicates if the account holds wrapped SOL.state
(string): The state of the token account (e.g., "initialized"
).parsed.type
(string): The type of the account (e.g., "account"
).executable
(boolean): Whether the account is executable.rentEpoch
(u64): The epoch at which this account will next owe rent.space
(u64, if jsonParsed
is not used): The length of the raw account data in bytes.jsonParsed
encoding):
mint
or programId
in the filter parameter. You cannot query for all delegated accounts across all token types without one of these filters."jsonParsed"
for the encoding
option is highly recommended for easier data handling, as it decodes the binary account data into a structured JSON format.programId
can be more resource-intensive than querying with mint
, especially if the delegate has authority over many different token types. Some RPC providers may have stricter rate limits for this method.delegatedAmount
in the response indicates the maximum number of tokens the delegate is currently authorized to use. This can be less than the total tokenAmount
in the account.Revoke
instruction to the SPL Token Program.getTokenAccountsByDelegate
to find SPL Token accounts based on their approved delegate.