getProgramAccounts

Returns all accounts owned by the specified program.

Request

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getProgramAccounts",
  "params": [
    "<programId>",
    {
      "encoding": "base64",
      "filters": [],
      "dataSlice": { "offset": 0, "length": 100 },
      "withContext": false
    }
  ]
}

Parameters

Parameter
Type
Required
Description

programId

string

Yes

Base58-encoded program public key

encoding

string

No

"base64" (default), "base58", or "base64+zstd"

filters

array

No

Filter results using dataSize or memcmp

dataSlice

object

No

Limit returned data to { offset, length }

withContext

bool

No

If true, wraps result in { context: { slot }, value: [...] }

limit

integer

No

Max results per page (1–10,000, default 1,000). Enables pagination

after

string

No

Cursor pubkey for pagination. Returns results after this key

Filters

dataSize

Only return accounts with the specified data length in bytes.

memcmp

Field
Type
Description

offset

integer

Byte offset into account data

bytes

string

Encoded bytes to match

encoding

string

"base58" (default) or "base64"

Response (Standard)

Response (with withContext: true)

Response (Paginated — when limit or after is provided)

Field
Type
Description

accounts

array

Array of account objects

paginationKey

string or null

Pass as after in next request. null = last page

totalResults

integer

Total matching accounts across all pages

Example

Large Query Protection

Queries that would return more than 100,000 accounts (or 10,000 for Token Program / Token-2022) are automatically rejected with a -32600 error directing you to use getProgramAccountsV2 with pagination instead.

This applies to unfiltered or broadly-filtered V1 requests. To avoid this, either:

  • Use getProgramAccountsV2 with limit and paginationKey for large result sets

  • Add dataSize or memcmp filters to narrow results below the threshold

Example error response:

Error Codes

Code
Message
Description

-32600

Too many accounts requested

Result set too large for V1. Use V2 with pagination

-32602

Invalid params

Missing or malformed parameters

-32004

Program is still indexing

Data not yet available, retry shortly

-32603

Internal error

Server-side error

Last updated