getTokenAccountsByDelegate — Solana JSON-RPC
Returns all SPL Token accounts that have approved a given delegate, filtered by mint or by token program.
https://triport.io/sol- Network
- Solana
- Scope
- sol_read_rpc
- Auth
- x-token: $TRIPORT_API_KEY (or Authorization: Bearer)
- Rate limit
- free+ — 20 rps (free) / 60 rps (basic) / 200 rps (pro) / 600 rps (business), with burst
Endpoint and plans: Solana RPC endpoint.
getTokenAccountsByDelegate returns every SPL Token account whose delegate
authority has been set to the public key you provide. When a token-account owner
calls approve, they grant a delegate the right to transfer up to a fixed
amount on their behalf; this method enumerates all accounts that have named a
particular delegate.
You must narrow the query with exactly one filter — either a specific mint
(only accounts of that token) or a programId (all accounts owned by that token
program, typically the SPL Token or Token-2022 program). The result is a
positional value array of { pubkey, account } pairs read at a single slot,
so the set is internally consistent.
Use jsonParsed encoding to get a decoded token-account object (mint, owner,
delegate, token amount) instead of raw bytes — this is usually what you want for
displaying delegated balances. This is the delegate-keyed counterpart of
getTokenAccountsByOwner, which keys by the
account owner instead.
Parameters
Positional params array: [delegate, filter, config?].
delegatestring (base-58 Pubkey)required^[1-9A-HJ-NP-Za-km-z]{32,44}$.filterobject (TokenAccountsFilter)requiredmint or programId (see below).configobject (GetTokenAccountsConfig)optionalfilter (TokenAccountsFilter)objectmintstring (base-58 Pubkey)programIdstring (base-58 Pubkey)TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA).config (GetTokenAccountsConfig)objectencodingstringoptionalbase58, base64, base64+zstd, jsonParsed. Use jsonParsed for a decoded token-account object. base58 is limited to account data under 129 bytes.commitmentstringoptionalprocessed, confirmed, or finalized.dataSliceobjectoptional{ "offset": <integer>, "length": <integer> }. Only valid with the binary encodings.minContextSlotintegeroptionalResponse
Response fields
The result is a TokenAccountsResponse: an RpcContext plus a value array
of { pubkey, account } pairs.
| Field | Type | Description |
|---|---|---|
context.slot | integer | Slot at which all accounts were evaluated. |
context.apiVersion | string | Version of the RPC node that served the request. |
value | array | One entry per matching token account. Empty if the delegate has no approved accounts under the filter. |
value[i].pubkey | string (base-58) | Address of the token account. |
value[i].account | object (AccountInfo) | The account state (see below). |
value[i].account.lamports | integer | Balance of the account in lamports. |
value[i].account.owner | string (base-58) | Public key of the program that owns the account (the token program). |
value[i].account.executable | boolean | Whether the account holds a loaded program (always false for token accounts). |
value[i].account.rentEpoch | integer | Epoch at which this account will next owe rent (u64). |
value[i].account.space | integer | Size of the account data in bytes. |
value[i].account.data | object | array | Account data. For jsonParsed: a decoded token-account object. For binary encodings: [<data>, <encoding>]. |
Errors
Errors use the standard JSON-RPC envelope (error.code, error.message,
error.data).
| Code | HTTP | Meaning | When it happens |
|---|---|---|---|
-32602 | 400 | Invalid params | delegate is not valid base-58, the filter is missing or specifies neither/both of mint/programId, or config contains an invalid value (e.g. base58 encoding on data larger than 129 bytes). |
| — | 403 | Tier insufficient | API key's tier/scope does not include sol_read_rpc. Rejected before the RPC layer: plain HTTP body {"error":"tier_insufficient", …} with an X-Required-Tier header — there is no JSON-RPC error object. |
| — | 429 | Rate limit exceeded | More than your tier's sustained RPS (with burst) was sent. Plain HTTP body {"error":"rate_limited", …} with limit_rps, burst_capacity and retry_after_sec; honour Retry-After and X-RateLimit-Reset. |
-32601 | 404 | Method not found | Method name misspelled or not available on this chain. |
Example rate-limit response — HTTP 429 with a plain body, not a JSON-RPC envelope:
{
"error": "rate_limited",
"message": "Rate limit reached: your free plan allows 20 requests/s for sol_read_rpc. Retry in 1s (see the Retry-After header) or upgrade for a higher limit at https://triport.io/app/pricing",
"current_tier": "free",
"category": "sol_read_rpc",
"limit_rps": 20,
"burst_capacity": 40,
"retry_after_sec": 1,
"upgrade_url": "https://triport.io/app/pricing",
"docs_url": "https://triport.io/errors/http-429-rate-limit"
}See the shared errors reference for the full envelope and retry guidance.
Examples
JavaScript (fetch)
const res = await fetch("https://triport.io/sol", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.TRIPORT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "getTokenAccountsByDelegate",
params: [
"4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA",
{ programId: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" },
{ encoding: "jsonParsed", commitment: "finalized" },
],
}),
});
const { result } = await res.json();
result.value.forEach(({ pubkey, account }) => {
const info = account.data.parsed.info;
console.log(pubkey, info.mint, info.delegatedAmount.uiAmountString);
});Notes
- Exactly one filter: the
filterobject must carry eithermintorprogramId, not both and not neither. Usemintto scope to a single token; useprogramId(the SPL Token or Token-2022 program) to enumerate every delegated account across all mints. - Delegate vs. owner: this method matches the token account's delegate
authority, not its owner. To list accounts by their owner instead, use
getTokenAccountsByOwner. - Use
jsonParsed: for token accounts,jsonParseddecodes the layout intomint,owner,delegate,delegatedAmount, andtokenAmount, which is far easier to work with than raw bytes. Binary encodings (base64,base64+zstd) return the account as a[data, encoding]tuple;base58only works for data under 129 bytes. - Consistent snapshot: all accounts are read at the single
context.slot, so the returned set is internally consistent. - Commitment: use
confirmedorprocessedto see changes sooner when you can tolerate possible rollbacks;finalizedis the safest choice for settled state. - Related methods:
getTokenAccountsByOwner(by owner),getTokenLargestAccounts, andgetAccountInfo(a single account by its address).