getProgramAccounts RPC Method
Returns all accounts owned by the provided program Pubkey
params
string
required
Pubkey of program, as base-58 encoded string
object
optional
Configuration object containing the following fields:commitment
The commitment describes how finalized a block is at that point in time. See Configuring State Commitment.
minContextSlot
The minimum slot that the request can be evaluated at
withContext
Wrap the result in an RpcResponse JSON object
dataSlice
Request a slice of the account's data.
length: <usize>
- number of bytes to returnoffset: <usize>
- byte offset from which to start reading
filters
Filter results using up to 4 filter objects.
result
array
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:
null
- if the account at that Pubkey doesn't exist, or- Account objects with the following fields:
pubkey
The account Pubkey as base-58 encoded string
owner
Base-58 encoded Pubkey of the program this account has been assigned to
account
A JSON object containing:
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
cURL
curl https://api.mainnet.openverse.network/ -s -X \
POST -H "Content-Type: application/json" -d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getProgramAccounts",
"params": [
"4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T",
{
"filters": [
{ "dataSize": 17 },
{
"memcmp": {
"offset": 4,
"bytes": "3Mc6vR"
}
}
]
}
]
}
'
Response
{
"jsonrpc": "2.0",
"result": [
{
"pubkey": "CxELquR1gPP8wHe33gZ4QxqGB3sZ9RSwsJ2KshVewkFY",
"account": {
"data": "2R9jLfiAQ9bgdcw6h8s44439",
"executable": false,
"lamports": 15298080,
"owner": "4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T",
"rentEpoch": 28,
"space": 42
}
}
],
"id": 1
}