getProgramAccounts
Returns accounts owned by the specified program, optionally filtered by data content or size.
Request
{ "jsonrpc": "2.0", "id": 1, "method": "getProgramAccounts", "params": [ "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", { "commitment": "finalized", "encoding": "base64", "filters": [ { "dataSize": 165 }, { "memcmp": { "offset": 0, "bytes": "Gh9ZwEmdLJ8DscKNTkTqPbNwLNNBjuSzaG9Vp2KGtKJr" } }, { "memcmp": { "offset": 32, "bytes": "5wx11hXBHQALycTQNkeQ5w1N9vgup4ardN2yLiDK4JyK" } } ], "sortResults": true } ]}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| pubkey | string | Yes | Pubkey of the program to query, as a base-58 encoded string. |
| commitment | string | No | Commitment level: processed | confirmed | finalized. Defaults to finalized. |
| minContextSlot | number | No | The minimum slot at which the request can be evaluated. |
| withContext | bool | No | When true, wraps the result in an RpcResponse JSON object. Defaults to false. |
| encoding | string | No | Encoding for account data: base64 (recommended) | base58 | base64+zstd | jsonParsed | binary (deprecated). Defaults to binary. |
| dataSlice | object | No | Return a byte slice of account data: { offset, length }. Only available for base58, base64, base64+zstd, and binary encodings. |
| filters | array | No | Up to 4 filter objects. Accounts must satisfy all filters to be included. Supported filter types: memcmp, dataSize, tokenAccountState. |
| sortResults | bool | No | Whether to sort accounts before returning. Defaults to true. When disabled, response order is undefined. |
Filter types
The filters parameter accepts up to 4 filter objects. An account must satisfy all provided filters to be included in the result.
| Filter type | Value type | Description |
|---|---|---|
| memcmp | object | Compares a byte sequence against account data at a given offset. Fields: offset (usize), bytes (base-58 string by default, base-64 when encoding is "base64", or raw byte array), encoding (optional — "base58", "base64", or "bytes"). Decoded data is limited to 128 bytes. |
| dataSize | u64 | Compares the account data length with the provided size. Only accounts whose data is exactly this many bytes are returned. |
| tokenAccountState | N/A | Filters for Token or Token-2022 accounts that have been initialized. No value required. |
Encoding options
| Encoding | Data format | Notes |
|---|---|---|
| base64 | [data, "base64"] | Recommended encoding. |
| base58 | [data, "base58"] | Slow. Account data must be 128 bytes or fewer. |
| base64+zstd | [data, "base64+zstd"] | Zstandard-compressed data. |
| jsonParsed | {program, parsed, space} | Structured JSON when a parser exists for the owner program. Falls back to [data, "base64"] when no parser is available. |
| binary | string | Deprecated default. Same as base58 but returns data as a plain string. Use base64 instead. |
Response
{ "jsonrpc": "2.0", "result": [ { "pubkey": "CxELquR1gPP8wHe33gZ4QxqGB3sZ9RSwsJ2KshVewkFY", "account": { "data": [ "KgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==", "base64" ], "executable": false, "lamports": 15298080, "owner": "4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T", "rentEpoch": 28, "space": 42 } } ], "id": 1}By default, returns an array of JSON objects. If withContext is true, the array is wrapped in an RpcResponse JSON object.
| Field | Type | Description |
|---|---|---|
| pubkey | string | The account public key as a base-58 encoded string. |
| account | object | Account data object — see fields below. |
| account.data | string | [string, encoding] | object | Account data. Binary forms depend on the encoding parameter. When encoding is jsonParsed, this is { program, parsed, space }; falls back to [data, "base64"] if no parser is available. |
| account.executable | bool | Whether the account contains a program and is therefore read-only. |
| account.lamports | u64 | Lamports assigned to the account. |
| account.owner | string | Program owner pubkey as a base-58 encoded string. |
| account.rentEpoch | u64 | Next epoch at which the account owes rent. |
| account.space | u64 | null | Account data size in bytes. Populated for encoded account responses. |