> For the complete documentation index, see [llms.txt](https://docs.triton.one/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.triton.one/solana/rpc-methods/readme/getprogramaccounts.md).

# getProgramAccounts

Returns accounts owned by a program, optionally filtered by memcmp or dataSize; on shared endpoints SPL Token, Token-2022, and System Program need memcmp.

{% hint style="warning" %}
On Triton shared endpoints, `getProgramAccounts` needs filters only for these programs:

* **SPL Token and Token-2022:** a `memcmp` filter on the owner (offset `32`) or the mint (offset `0`), with the full 32-byte public key. A shorter `bytes` value returns error `-32602`.
* **System Program:** at least one `memcmp` filter.

Calls to these programs with no `memcmp` at the required offset are rejected with HTTP `403` ("Your IP or provider is blocked from this endpoint"). Every other program is served from Cloudbreak's index, with or without filters, except a few excluded programs, which return error `-32010`:

* Serum DEX v3 (`9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin`)
* Candy Machine v1 and v2 (`cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ`, `cndy3Z4yapfJBmL3ShUp5exZKqR3z33thTzeNMm2gRZ`)
* Legacy Metaplex auction programs (`auctxRXPeJoc4817jDhf4HbjnhEcr1cCXenosMhK5R8`, `p1exdMJcjVao65QdewkaZRUnU6VPSXhus9n2GzWfh98`)
* Kin token mint (`kinXdEcpDQeHPEuQnqmUgtYykqKGVFq6CeVX5iAHJq6`)

Light Protocol account compression (`compr6CUsB5m2jS4Y3831ztGSTnDpnKJTKS95d64XVq`) is served by standard RPC nodes on shared endpoints, without Cloudbreak's index. Filtering with `memcmp` or `dataSize` keeps large queries fast.
{% endhint %}

{% hint style="info" %}
Cloudbreak also differs from Agave here: `processed` is answered at `confirmed`, results are always sorted by pubkey (`sortResults: false` has no effect), and there's no limit on the number of filters. Like Agave, Cloudbreak checks `minContextSlot` on every call and returns error `-32016` if the index hasn't reached that slot.

Queries have a 45-second limit, or 20 seconds for SPL Token and Token-2022 queries, which Cloudbreak's token index serves. A query that exceeds it returns error `-32603`, or ends the connection early if the response has already started. Responses have a 90-second limit; a response still streaming at the limit ends early, and your JSON parser reports an incomplete document. Treat both as a failed request and retry. Narrow large queries with filters or `dataSlice`.
{% endhint %}

## Request

{% tabs %}
{% tab title="cURL" %}

```bash
curl "https://<your-endpoint>.mainnet.rpcpool.com/<your-token>" -s -X POST \
  -H "Content-Type: application/json" \
  -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getProgramAccounts",
  "params": [
    "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
    {
      "commitment": "finalized",
      "encoding": "base64",
      "filters": [
        { "dataSize": 165 },
        {
          "memcmp": {
            "offset": 0,
            "bytes": "LSTxxxnJzKDFSLr4dUkPcmCf5VyryEqzPLz5j4bpxFp"
          }
        },
        {
          "memcmp": {
            "offset": 32,
            "bytes": "5wx11hXBHQALycTQNkeQ5w1N9vgup4ardN2yLiDK4JyK"
          }
        }
      ],
      "sortResults": true
    }
  ]
}'
```

{% endtab %}

{% tab title="Kit" %}

```typescript
import { address, createSolanaRpc, type Base58EncodedBytes } from "@solana/kit";

const rpc_url = "https://<your-endpoint>.mainnet.rpcpool.com/<your-token>";
const rpc = createSolanaRpc(rpc_url);

let program = address("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");

let accounts = await rpc
  .getProgramAccounts(
    program,
    {
      commitment: "finalized",
      encoding: "base64",
      filters: [
        {
          dataSize: BigInt(165)
        },
        {
          memcmp: {
            bytes: "LSTxxxnJzKDFSLr4dUkPcmCf5VyryEqzPLz5j4bpxFp" as Base58EncodedBytes,
            encoding: "base58",
            offset: BigInt(0)
          }
        },
        {
          memcmp: {
            bytes: "5wx11hXBHQALycTQNkeQ5w1N9vgup4ardN2yLiDK4JyK" as Base58EncodedBytes,
            encoding: "base58",
            offset: BigInt(32)
          }
        }
      ]
    }
  )
  .send();

console.log(accounts);
```

{% endtab %}

{% tab title="web3.js" %}

```typescript
import {
  Connection,
  PublicKey,
  type GetProgramAccountsConfig
} from "@solana/web3.js";

const connection = new Connection("https://<your-endpoint>.mainnet.rpcpool.com/<your-token>", "confirmed");

let programId = new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");

let config: GetProgramAccountsConfig = {
  commitment: "finalized",
  encoding: "base64",
  filters: [
    {
      dataSize: 165
    },
    {
      memcmp: {
        bytes: "LSTxxxnJzKDFSLr4dUkPcmCf5VyryEqzPLz5j4bpxFp",
        offset: 0
      }
    },
    {
      memcmp: {
        bytes: "5wx11hXBHQALycTQNkeQ5w1N9vgup4ardN2yLiDK4JyK",
        offset: 32
      }
    }
  ]
};

let accounts = await connection.getProgramAccounts(programId, config);

console.log(accounts);
```

{% endtab %}

{% tab title="Rust" %}

```rust
// Cargo.toml: anyhow = "1", solana-account-decoder = "4", solana-client = "~4.4",
// solana-commitment-config = "3", solana-sdk = "5", tokio = { version = "1", features = ["full"] }.
// solana-client 4.4 takes solana-sdk 5.x types. Requires Rust 1.98.1 or newer (solana-client 4.4).
use anyhow::Result;
use solana_account_decoder::UiAccountEncoding;
use solana_client::{
    nonblocking::rpc_client::RpcClient,
    rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig},
    rpc_filter::{Memcmp, MemcmpEncodedBytes, RpcFilterType},
};
use solana_commitment_config::CommitmentConfig;
use solana_sdk::pubkey;

#[tokio::main]
async fn main() -> Result<()> {
    let client = RpcClient::new_with_commitment(
        String::from("https://<your-endpoint>.mainnet.rpcpool.com/<your-token>"),
        CommitmentConfig::confirmed(),
    );

    let program = pubkey!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");

    let config = RpcProgramAccountsConfig {
        filters: vec![
            RpcFilterType::DataSize(165),
            RpcFilterType::Memcmp(Memcmp::new(
                0,
                MemcmpEncodedBytes::Base58("LSTxxxnJzKDFSLr4dUkPcmCf5VyryEqzPLz5j4bpxFp".to_string()),
            )),
            RpcFilterType::Memcmp(Memcmp::new(
                32,
                MemcmpEncodedBytes::Base58("5wx11hXBHQALycTQNkeQ5w1N9vgup4ardN2yLiDK4JyK".to_string()),
            )),
        ]
        .into(),
        account_config: RpcAccountInfoConfig {
            encoding: UiAccountEncoding::Base64.into(),
            data_slice: None,
            commitment: CommitmentConfig::finalized().into(),
            min_context_slot: None,
        },
        with_context: None,
        sort_results: true.into(),
    };

    let accounts = client
        .get_program_ui_accounts_with_config(&program, config)
        .await?;

    println!("{:#?}", accounts);

    Ok(())
}
```

{% endtab %}
{% endtabs %}

## Parameters

**`pubkey`** · string · required

Pubkey of program, as base-58 encoded string

**`config`** · object

Configuration object containing the following fields:

**`commitment`** · string · default `finalized`

Values: `processed`, `confirmed`, `finalized`

Solana RPC uses the following commitment levels:

| Value       | Description                                                                                                                                                                        |
| ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `processed` | Return data from the highest slot this node has processed on the fork it currently considers best. This is the newest view, but it can still change if the cluster switches forks. |
| `confirmed` | Return data from the highest slot the cluster has finalized. On Alpenglow, `confirmed` and `finalized` are the same level.                                                         |
| `finalized` | Return data from the highest slot that the cluster has finalized. On Alpenglow there are no vote towers or lockouts: a slot is finalized by certificates of aggregated votes.      |

**`minContextSlot`** · number

The minimum slot that the request can be evaluated at

**`withContext`** · bool · default `false`

Values: `true`, `false`

Wrap the result in an RpcResponse JSON object

**`encoding`** · string · default `binary`

Values: `base58`, `base64`, `base64+zstd`, `binary`, `jsonParsed`

Encoding format for account data.

| Encoding      | Data format                | Notes                                                                                                                                                                                                                            |
| ------------- | -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `base64`      | `[data, "base64"]`         | Recommended                                                                                                                                                                                                                      |
| `base58`      | `[data, "base58"]`         | Slow. The account's data field must be 128 bytes or fewer                                                                                                                                                                        |
| `base64+zstd` | `[data, "base64+zstd"]`    | [Zstandard](https://facebook.github.io/zstd/) compressed                                                                                                                                                                         |
| `jsonParsed`  | `{program, parsed, space}` | Falls back to `[data, "base64"]` if no parser found                                                                                                                                                                              |
| `binary`      | `string`                   | Deprecated default. Legacy encoding retained for backwards compatibility. Same base58 encoding as `base58` with the same 128-byte data field limit, but returns data as a plain string instead of an array. Use `base64` instead |

{% hint style="warning" %}
Always set `encoding` to `base64` or `jsonParsed`. The default `binary` returns error `-32600` for any account with more than 128 bytes of data, and every token account is 165 bytes or more.
{% endhint %}

If you use `jsonParsed`, each returned account uses the stable wrapper `{program, parsed, space}`. The `program` field identifies the parser that produced `parsed`. If no parser is available, the RPC node falls back to `[data, "base64"]`.

| `program` value          | Parsed account type                            |
| ------------------------ | ---------------------------------------------- |
| `address-lookup-table`   | Address lookup table accounts                  |
| `bpf-upgradeable-loader` | Upgradeable loader program and buffer accounts |
| `config`                 | Config accounts                                |
| `nonce`                  | Durable nonce accounts                         |
| `spl-token`              | SPL Token accounts                             |
| `spl-token-2022`         | SPL Token 2022 accounts                        |
| `stake`                  | Stake accounts                                 |
| `sysvar`                 | Sysvar accounts                                |
| `vote`                   | Vote accounts                                  |

The nested `parsed` payload remains program-specific.

For the shared account wrapper returned in each `account` field, see [Account Data](https://solana.com/docs/rpc/json-structures#account-data).

**`dataSlice`** · object

Request a slice of the account's data.

| Field    | Type    | Description                                           |
| -------- | ------- | ----------------------------------------------------- |
| `offset` | `usize` | Byte offset from which to start reading account data. |
| `length` | `usize` | Number of bytes to return.                            |

{% hint style="info" %}
Data slicing applies to `base58`, `base64`, `base64+zstd`, and `binary` encodings. With `jsonParsed`, the slice applies only to accounts that fall back to `[data, "base64"]`; parsed accounts are returned in full.
{% endhint %}

**`filters`** · array

Filter results using filter objects. Agave allows up to 4. Cloudbreak, which serves this method on Triton, has no limit. The resultant account(s) must meet **all** filter criteria to be included in the returned results.

The following filter types are supported:

| Filter              | Type     | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `memcmp`            | `object` | Compares a provided series of bytes with account data at a particular offset. Fields: `offset` (`usize`), byte offset into account data; `bytes` (`string \| array`), data to match, provided as a base-58 string by default, a base-64 string when `encoding` is `"base64"`, or a raw byte array; `encoding` (`string`, optional), encoding for string `bytes`, either `"base58"` (default), `"base64"`, or `"bytes"`. Decoded data is limited to 128 bytes. |
| `dataSize`          | `u64`    | Compares the account data length with the provided size.                                                                                                                                                                                                                                                                                                                                                                                                      |
| `tokenAccountState` | N/A      | Matches accounts with the token-account layout: data of exactly 165 bytes, or longer with account type `2` at byte 165. On Triton the match is on layout only, so an uninitialized account with that layout also matches. No value is needed.                                                                                                                                                                                                                 |

**`sortResults`** · bool · default `true`

Values: `true`, `false`

Whether to sort returned accounts before returning them. If disabled, do not assume any particular response order. On Triton, results are always sorted by pubkey.

## Response

```json
{
  "jsonrpc": "2.0",
  "result": [
    {
      "pubkey": "CxELquR1gPP8wHe33gZ4QxqGB3sZ9RSwsJ2KshVewkFY",
      "account": {
        "data": [
          "KgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
          "base64"
        ],
        "executable": false,
        "lamports": 15298080,
        "owner": "4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T",
        "rentEpoch": 28,
        "space": 42
      }
    }
  ],
  "id": 1
}
```

## Result

By default, returns an array of JSON objects. If `withContext` flag is set, the array will be wrapped in an RpcResponse JSON object.

Each object contains:

**`pubkey`** · string

The account Pubkey as base-58 encoded string

**`account`** · object

Account data object.

This field uses the shared [Account Data](https://solana.com/docs/rpc/json-structures#account-data) structure.

| Field        | Type                                     | Description                                                                                                                                                                                                         |
| ------------ | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `data`       | `string \| [string, encoding] \| object` | Account data. Binary forms depend on the `encoding` parameter. When `encoding` is `jsonParsed`, this field is `{program, parsed, space}`; if no parser is available, the RPC node falls back to `[data, "base64"]`. |
| `executable` | `bool`                                   | Whether the account contains a program and is therefore read-only.                                                                                                                                                  |
| `lamports`   | `u64`                                    | Lamports assigned to the account.                                                                                                                                                                                   |
| `owner`      | `string`                                 | Program owner pubkey, as a base-58 encoded string.                                                                                                                                                                  |
| `rentEpoch`  | `u64`                                    | Legacy field. Solana no longer collects rent, and rent-exempt accounts report `18446744073709551615` (u64::MAX).                                                                                                    |
| `space`      | `u64 \| null`                            | Account data size in bytes. Current Solana RPC responses populate this field for encoded account responses.                                                                                                         |

When `account.data` is returned as an object, it contains:

| Field     | Type     | Description                                                                                 |
| --------- | -------- | ------------------------------------------------------------------------------------------- |
| `program` | `string` | Name of the parser that produced the decoded account data.                                  |
| `parsed`  | `object` | Parser-specific JSON payload. Its structure depends on the owning program and account type. |
| `space`   | `u64`    | Account data size in bytes.                                                                 |

***

*Adapted from the* [*Solana `getProgramAccounts` reference*](https://solana.com/docs/rpc/http/getprogramaccounts)*, maintained by the Solana Foundation.*

***

<i class="fa-life-ring">:life-ring:</i> Contact support by clicking the chat icon in your [customer dashboard](https://customers.triton.one)\ <i class="fa-briefcase">:briefcase:</i> Sales questions? [Contact us](https://triton.one/contact)\ <i class="fa-sparkles">:sparkles:</i> AI agent? Read [llms.txt](https://docs.triton.one/llms.txt)\ <i class="fa-rss">:rss:</i> Follow updates: [Blog](https://blog.triton.one) · [X](https://x.com/triton_one) · [YouTube](https://www.youtube.com/@triton_one_ltd) · [Telegram](https://t.me/tritonone) · [GitHub](https://github.com/rpcpool)
