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 dataDetails
base58is slow and limited to less than 129 bytes of Account data. -base64will return base64 encoded data for Account data of any size. -base64+zstdcompresses the Account data using Zstandard and base64-encodes the result. -jsonParsedencoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. - IfjsonParsedis requested but a parser cannot be found, the field falls back tobase64encoding, detectable when thedatafield is typestring.
-
dataSlice: <object>- Request a slice of the account's datalength: <usize>- number of bytes to returnoffset: <usize>- byte offset from which to start readingDetails
Data slicing is only available for
base58,base64, orbase64+zstdencodings.
-
filters: array<object>- filter results using up to 4 filter objectsDetails
The resultant account(s) must meet ALL filter criteria to be included in the returned results
memcmp: <object>- filter accounts by data contentsoffset: <usize>- byte offset from which to start comparingbytes: <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 stringaccount: <object>- a JSON object, with the following sub fields:lamports: <u64>- number of lamports assigned to this account, as a u64owner: <string>- base-58 encoded Pubkey of the program this account has been assigned todata: <[string,encoding]|object>- data associated with the account, either as encoded binary data or JSON format{<program>: <state>}- depending on encoding parameterexecutable: <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 u64space: <u64>- the data size of the account
Code sample
curl "https://testnet.atlas.xyz" -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
}
}
]
}