OpenInfra.sh is now live - Solana infrastructure, included with every server. LEARN MORE HERE >

OpenInfra.shopeninfra.sh

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

ParameterTypeRequiredDescription
pubkeystringYesPubkey of the program to query, as a base-58 encoded string.
commitmentstringNoCommitment level: processed | confirmed | finalized. Defaults to finalized.
minContextSlotnumberNoThe minimum slot at which the request can be evaluated.
withContextboolNoWhen true, wraps the result in an RpcResponse JSON object. Defaults to false.
encodingstringNoEncoding for account data: base64 (recommended) | base58 | base64+zstd | jsonParsed | binary (deprecated). Defaults to binary.
dataSliceobjectNoReturn a byte slice of account data: { offset, length }. Only available for base58, base64, base64+zstd, and binary encodings.
filtersarrayNoUp to 4 filter objects. Accounts must satisfy all filters to be included. Supported filter types: memcmp, dataSize, tokenAccountState.
sortResultsboolNoWhether 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 typeValue typeDescription
memcmpobjectCompares 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.
dataSizeu64Compares the account data length with the provided size. Only accounts whose data is exactly this many bytes are returned.
tokenAccountStateN/AFilters for Token or Token-2022 accounts that have been initialized. No value required.

Encoding options

EncodingData formatNotes
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.
binarystringDeprecated 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.

FieldTypeDescription
pubkeystringThe account public key as a base-58 encoded string.
accountobjectAccount data object — see fields below.
account.datastring | [string, encoding] | objectAccount 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.executableboolWhether the account contains a program and is therefore read-only.
account.lamportsu64Lamports assigned to the account.
account.ownerstringProgram owner pubkey as a base-58 encoded string.
account.rentEpochu64Next epoch at which the account owes rent.
account.spaceu64 | nullAccount data size in bytes. Populated for encoded account responses.