Skip to main content

getTokenAccountsByDelegate

Returns all SPL Token accounts by approved Delegate.

Common use cases
Monitor Staking PositionsTrack tokens delegated to staking programs across your wallet. Query with programId filter set to staking program's ID and jsonParsed encoding to see delegatedAmount field showing how many tokens are actively staked. Essential for portfolio aggregators displaying locked vs. liquid balances.
Verify Escrow & Lending CollateralAudit delegated token accounts in DeFi protocols (lending, escrow, vaults). Filter by specific mint to find all accounts where your wallet delegated authority for that token. Check delegatedAmount to confirm collateral matches expectations. Critical for risk monitoring in automated liquidation systems.
Display Complete Wallet PortfolioCombine with getTokenAccountsByOwner to show user's full token positions including delegated amounts. Use programId: TOKEN_PROGRAM_ID filter with jsonParsed encoding. Parse both owned tokens and delegated permissions in unified UI. Common pattern in wallet apps showing "Available" vs "Staked" balances.
Audit Delegate PermissionsSecurity check to discover all token accounts where a wallet has been granted delegate authority. Iterate results to identify unexpected permissions or forgotten delegations that should be revoked. Important for wallet hygiene and permission management tools.
Migrate Token Program AccountsIdentify legacy SPL Token accounts (TOKEN_PROGRAM_ID) vs. Token-2022 accounts (TOKEN_2022_PROGRAM_ID) by filtering separately. Query both program IDs with same delegate to audit which program version holds delegated tokens. Used in migration scripts moving from legacy to Token-2022.

Parameters

pubkey (string, required)

Pubkey of account delegate to query, as base-58 encoded string

config (object, required)

A JSON object with one of the following fields:

Fields:

  • mint (string): Pubkey of the specific token Mint to limit accounts to, as base-58 encoded string; or

options (object, optional)

Configuration object containing the following fields:

Fields:

  • commitment (string): The commitment describes how finalized a block is at that point in time. See Configuring State Commitment.
  • minContextSlot (number): The minimum slot that the request can be evaluated at
  • dataSlice (object): Request a slice of the account's data.
    • length: <usize> - number of bytes to return
    • offset: <usize> - byte offset from which to start reading Data slicing is only available for base58, base64, or base64+zstd encodings.
  • encoding (string): Encoding format for Account data
    • base58 is slow and limited to less than 129 bytes of Account data.
    • base64 will return base64 encoded data for Account data of any size.
    • base64+zstd compresses the Account data using Zstandard and base64-encodes the result.
    • binary (⚠️ deprecated) is similar to base58, except data will be a base58-encoded string and not an array that includes the encoding.
    • jsonParsed encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data.
    • If jsonParsed is requested but a parser cannot be found, the field falls back to base64 encoding, detectable when the data field is type string.

Request

curl https://solana-mainnet.api.syndica.io/api-key/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getTokenAccountsByDelegate",
"params": [
"4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T",
{
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
},
{
"commitment": "finalized",
"encoding": "jsonParsed"
}
]
}'
Network Selection

Replace mainnet with devnet in the URL to query devnet instead.

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
}

Response Fields

Return value: array

An array of JSON objects containing:

FAQ and Troubleshooting

When should I use getTokenAccountsByDelegate vs. getTokenAccountsByOwner?

Use getTokenAccountsByDelegate to find accounts where a wallet has been granted delegate authority (staking, escrow, lending). Use getTokenAccountsByOwner to find accounts the wallet actually owns. Delegate = permission to transfer up to delegatedAmount; Owner = original account ownership. Same filter types (mint/programId) and encoding options apply to both.

Does jsonParsed encoding always work for this method?

Yes. The RPC node always knows how to parse SPL token account structures, so jsonParsed never falls back to base64 encoding like it might for custom program accounts. Use jsonParsed for automatic parsing of mint, owner, amount, delegate, and delegatedAmount fields.

Why isn't getTokenAccountsByDelegate available in @solana/web3.js Connection class?

The method is only in the new experimental @solana/rpc-api package (e.g., @solana/rpc-api@2.0.0-preview.3), not the legacy @solana/web3.js Connection class. This is a common SDK confusion. For legacy SDK users, make direct JSON-RPC calls or upgrade to the new SDK architecture.

Can I filter by both mint AND programId at the same time?

No, the TokenAccountsFilter parameter requires EITHER {"mint": "<mint-pubkey>"} OR {"programId": "<program-id>"}, not both. Use mint filter when checking a specific token's delegated accounts; use programId filter (e.g., TOKEN_PROGRAM_ID) to find all SPL Token delegated accounts regardless of mint.

What does the 'delegatedAmount' field represent?

The delegatedAmount field (visible with jsonParsed encoding) shows the maximum number of tokens the delegate can transfer from this account. It's token-specific (not lamports). If delegatedAmount is 100 and account has 1000 tokens, delegate can transfer up to 100. Amount is in token's native units (multiply by decimals for UI display).

getTokenAccountsByOwner
Returns token accounts by original owner instead of delegate. Use when you need accounts the wallet owns (not just has permission to use). Pair with getTokenAccountsByDelegate to build complete portfolio view showing owned + delegated positions. Same filter and encoding options.

getTokenAccountBalance
Returns balance for a specific token account with decimals. After using getTokenAccountsByDelegate to identify accounts, call this to refresh individual balances without rescanning all delegates. Both require same --account-index spl-token-owner flag on RPC node.

getProgramAccounts
Returns all accounts for a program with custom filtering. Alternative when you need complex filters beyond delegate (e.g., filtering by specific mint AND minimum balance). Slower and requires account-index flags, but more flexible than getTokenAccountsByDelegate for advanced queries.

getAccountInfo
Returns raw account data for any account type. Use when you need non-token account details or want to manually parse token account data instead of using jsonParsed encoding. Requires knowing specific account pubkey (can get from getTokenAccountsByDelegate results).

getTokenSupply
Returns total supply for a token mint. Pair with getTokenAccountsByDelegate when analyzing delegate distribution or calculating percentage of supply delegated. Essential for token concentration metrics showing what portion of supply is actively delegated (staked/locked).

External Resources

  • Solana Official Documentation
  • SPL Token Program - Delegate Authority - Official SPL Token documentation explaining delegate field semantics, delegatedAmount calculations, and the Approve instruction that creates delegate relationships. Essential reading for understanding what this RPC method returns.
  • Anza web3.js 2.0 - RPC API Package - TypeScript SDK implementation for new web3.js architecture. Contains getTokenAccountsByDelegate type definitions and usage examples. Reference for developers migrating from legacy SDK or building with modern Solana web3 stack.