getProgramAccounts
Returns all accounts owned by the provided program Pubkey

Parameters

  • <base-58 encoded strings> - Pubkey of program
  • <object> - (optional) Config object:
    • encoding: (optional) <string> - data encoding for each returned transaction
    Accepts one of the following strings: ["json" (Default), "jsonParsed", "base58" (slow), "base64", "base64+zstd"] "jsonParsed" encoding attempts to use program-specific parsers to make the transaction.message.instructions list more human-readable; if a parser cannot be found, the instruction falls back to default JSON.
    • dataSlice: (optional) <object> - limit the returned account data using the provided offset: <usize> and length: <usize> fields; only available for "base58", "base64" or "base64+zstd" encodings.
    • filters: (optional) <array> - filter results using various filter objects; account must meet all filter criteria to be included in results
      • memcmp: <object> - compares a provided series of bytes with program account data at a particular offset. Fields:
        • offset: <usize> - offset into program account data to start comparison
        • bytes: <string> - data to match, as base-58 encoded string and limited to less than 129 bytes
      • dataSize: <u64> - compares the program account data length with the provided data size
    • withContext: (optional) <bool> - wrap the result in an RpcResponse JSON object.
    • minContextSlot: (optional) <number> - set the minimum slot that the request can be evaluated at.

Result

  • pubkey: <base-58 encoded string> - the account Pubkey
  • account: <object> - a JSON object, with the following sub fields
    • lamports: <u64>, number of lamports assigned to this account
    • owner: < base-58 encoded string>, Pubkey of the program this account has been assigned to
    • data: <[string, encoding]|object>, data associated with the account, either as encoded binary data or JSON format {<program>: <state>}, depending on encoding parameter
    • executable: <bool>, boolean indicating if the account contains a program (and is strictly read-only)
    • rentEpoch: <u64>, the epoch at which this account will next owe rent

Example

Request

cURL
1
curl --location --request POST 'https://solana-mainnet.g.alchemy.com/v2/alch-demo/' \
2
--header 'Content-Type: application/json' \
3
--data-raw '{
4
"method": "getProgramAccounts",
5
"jsonrpc": "2.0",
6
"params": [
7
"Stake11111111111111111111111111111111111111",
8
{
9
"encoding": "jsonParsed",
10
"commitment": "recent",
11
"filters": [
12
{
13
"memcmp": {
14
"offset": 44,
15
"bytes": "65qFmhCmDgXjg1duFdcpYyPheWyWGyusZhy3Y8khMoYm"
16
}
17
}
18
]
19
}
20
],
21
"id": "566965b3-7c1a-4338-b424-430b3240976e"
22
}'
Copied!

Response

1
{
2
"jsonrpc": "2.0",
3
"result": [
4
{
5
"account": {
6
"data": "2R9jLfiAQ9bgdcw6h8s44439",
7
"executable": false,
8
"lamports": 15298080,
9
"owner": "4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T",
10
"rentEpoch": 28
11
},
12
"pubkey": "CxELquR1gPP8wHe33gZ4QxqGB3sZ9RSwsJ2KshVewkFY"
13
}
14
],
15
"id": 1
16
}
Copied!