Skip to main content

getProgramAccounts

Returns all accounts owned by the provided program Pubkey

Parameters

Pubkey string

  • Pubkey of program, as base-58 encoded string

Configuration <object>

  • Configuration object containing the following fields:

    • encoding: <string> - encoding format for Account data

      Details
      • base58 is slow and limited to less than 129 bytes of Account data. - base64 will return base64 encoded data for Account data of any size. - base64+zstd compresses the Account data using Zstandard and base64-encodes the result. - jsonParsed encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. - If jsonParsed is requested but a parser cannot be found, the field falls back to base64 encoding, detectable when the data field is type string.
    • dataSlice: <object> - Request a slice of the account's data

      • length: <usize> - number of bytes to return
      • offset: <usize> - byte offset from which to start reading
        Details

        Data slicing is only available for base58, base64, or base64+zstd encodings.

    • filters: array<object> - filter results using up to 4 filter objects

      Details

      The resultant account(s) must meet ALL filter criteria to be included in the returned results

      • memcmp: <object> - filter accounts by data contents
        • offset: <usize> - byte offset from which to start comparing
        • bytes: <string> - base-58 encoded bytes to compare against
      • dataSize: <usize> - filter accounts by data size

Result

By default, the result field will be an array of JSON objects.

The resultant response array will contain:

  • pubkey: <string> - the account Pubkey as base-58 encoded string
  • account: <object> - a JSON object, with the following sub fields:
    • lamports: <u64> - number of lamports assigned to this account, as a u64
    • owner: <string> - base-58 encoded 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, as u64
    • space: <u64> - the data size of the account

Code sample

curl "https://testnet.atlas.xyz/?apikey=$ATLAS_API_KEY" -X POST -H "Content-Type: application/json" -d '
{
"jsonrpc": "2.0",
"id": "0bdba4c1-3073-41b0-b849-46f14e004e38",
"method": "getProgramAccounts",
"params": [
"PhoeNiXZ8ByJGLkxNfZRnkUfjvmuYqLR89jjFHGqdXY",
{
"filters": [
{
"dataSize": 128
},
{
"memcmp": {
"offset": 8,
"bytes": "6fSYZCeLB3JFEXDa8Z4PQ3Jto8Bci4ydpNyofbUfbdV4"
}
}
]
}
]
}
'

Response

{
"jsonrpc": "2.0",
"id": "0bdba4c1-3073-41b0-b849-46f14e004e38",
"result": [
{
"pubkey": "GuRHzVicFyWqzYcZgiPhm1bXhnJo2BSDFyL8ky9ZvQUm",
"account": {
"lamports": 1781760,
"data": [
"iLdCH0etyhtUI2Ncl4zFO0WE0mDYkaAaLhKEhMa8wzgsp9SySxe+exisETe7Vg4LoRm1dpmxNtbB9RTG/mucX8eZ7ujWKpLrAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
"base64"
],
"owner": "PhoeNiXZ8ByJGLkxNfZRnkUfjvmuYqLR89jjFHGqdXY",
"executable": false,
"rentEpoch": 0,
"space": 128
}
},
{
"pubkey": "6CJpA6Dz1af9b9UXyL7XdHLU2BUzUV2igL3CqSnhMzMk",
"account": {
"lamports": 1781760,
"data": [
"iLdCH0etyhtUI2Ncl4zFO0WE0mDYkaAaLhKEhMa8wzgsp9SySxe+exxWkdO7tB2ImE0LOn/0YyQnOdQ8WeNeK1ACUAeD00PsAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
"base64"
],
"owner": "PhoeNiXZ8ByJGLkxNfZRnkUfjvmuYqLR89jjFHGqdXY",
"executable": false,
"rentEpoch": 0,
"space": 128
}
}
]
}