getProgramAccounts method returns all accounts owned by the provided program public key. This method is useful for retrieving the state of all accounts associated with a specific program — for example, all token accounts for a given mint or all positions in a DeFi protocol.
jsonParsed encoding and no filters. For large programs like Token-2022, you must add filters — see the examples below.programId — the base-58 encoded public key of the program to retrieve accounts for.config — configuration object containing the following fields. Must be provided even if empty ({}):
commitment (optional) — the level of commitment desired:
processed — the node has processed the block and the block may be on a fork.confirmed — the block is confirmed by the cluster as not being on a fork.finalized — the block is finalized by the cluster.encoding (optional) — the encoding for the returned account data:
base64 — recommended default. Fast and compact.base64+zstd — base64 with Zstandard compression. Best for large responses.jsonParsed — human-readable JSON. Only available for programs with a registered parser on the node (SPL Token, Stake, Vote). Falls back to base64 for other programs. Slowest option.base58 — legacy encoding. Limited to accounts with data under 129 bytes. Avoid in production.filters (optional) — an array of filter objects to narrow results. Up to 4 filters can be combined. See Filters.dataSlice (optional) — limits the returned account data to a specific byte range. When used with jsonParsed encoding, dataSlice is silently ignored and the response falls back to base64:
offset — byte offset to start reading from.length — number of bytes to return.minContextSlot (optional) — the minimum slot at which the request can be evaluated.withContext (optional) — when true, wraps the response in an RpcResponse object that includes the context field with the slot number at which the data snapshot was taken.dataSize — matches accounts whose data is exactly the specified number of bytes. Use this as the first filter to eliminate entire account types in one comparison:
165 — SPL Token account82 — SPL Token mint200 — Stake accountmemcmp — compares a sequence of bytes at a specific offset within the account’s raw data:
offset — byte position to start comparing.bytes — base-58 encoded value to match. Decoded length must not exceed 128 bytes.dataSize: 165 filter ensures only SPL Token accounts are considered, while the memcmp at offset 0 matches the mint address stored in the first 32 bytes of the token account data.
value — an array of account information objects, each containing:
pubkey — the base-58 encoded public key of the account.account — the account information:
lamports — the account’s current balance in lamports.owner — the base-58 encoded public key of the program that owns the account.data — the account’s data in the requested encoding. When using dataSlice, only the specified byte range is returned.executable — whether the account is marked as executable.rentEpoch — the epoch at which this account will next owe rent.space — the data size of the account in bytes.withContext: true is set, the response is wrapped in an RpcResponse object:
dataSize: 165 (SPL Token account size) and a memcmp filter matching the mint address at byte offset 0.
dataSlice, then fetch data in batches using getMultipleAccounts.
memcmp at offset 0.
getProgramAccounts is to retrieve the current state of all accounts associated with a specific Solana program. Common scenarios include:
memcmp on the mint addressgetProgramAccounts with withContext for slot-consistent snapshotsdataSize as the first filter, then memcmp for further narrowing.base64 encoding over jsonParsed for performance. Only use jsonParsed when you need human-readable output and the program has a registered parser.dataSlice to reduce response size when you only need specific fields from account data.getMultipleAccounts.getProgramAccounts has lower per-method RPS limits than standard calls.getProgramAccounts on the Token Program (TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA) or Kin (kinXdEcpDQeHPEuQnqmUgtYykqKGVFq6CeVX5iAHJq6) directly — these are excluded from indexing. Use getTokenAccountsByOwner instead.getProgramAccounts:
-32602 — unfiltered request blocked — returned when calling getProgramAccounts without filters on a large program (e.g., Token-2022). Add dataSize and/or memcmp filters.-32010 — program excluded from secondary index — returned when the program is too large to index (e.g., the Token Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA). Use getTokenAccountsByOwner instead.500 — missing config object — returned when the params array contains only the program ID without a configuration object. Always pass a config object as the second parameter, even if empty ({}).getTokenAccountsByOwner — faster alternative when querying SPL Token accounts by wallet address. Uses a dedicated secondary index.getMultipleAccounts — fetch up to 100 accounts by pubkey in a single call. Best combined with getProgramAccounts in the two-phase pattern.getAccountInfo — fetch a single account by pubkey.