getProgramAccounts RPC 方法

返回由提供的程序 Pubkey 拥有的所有账户

$ curl https://api.devnet.solana.com -s -X \
> POST -H "Content-Type: application/json" -d '
> {
> "jsonrpc": "2.0",
> "id": 1,
> "method": "getProgramAccounts",
> "params": [
> "4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T",
> {
> "commitment": "finalized",
> "filters": [
> { "dataSize": 17 },
> {
> "memcmp": {
> "offset": 4,
> "bytes": "3Mc6vR"
> }
> }
> ]
> }
> ]
> }
> '

params

stringrequired

程序的 Pubkey,以 base-58 编码的字符串形式

objectoptional

包含以下字段的配置对象:

result

Response
{
"jsonrpc": "2.0",
"result": [
{
"pubkey": "CxELquR1gPP8wHe33gZ4QxqGB3sZ9RSwsJ2KshVewkFY",
"account": {
"data": "2R9jLfiAQ9bgdcw6h8s44439",
"executable": false,
"lamports": 15298080,
"owner": "4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T",
"rentEpoch": 28,
"space": 42
}
}
],
"id": 1
}
array

默认情况下,返回一个 JSON 对象数组。如果设置了 withContext 标志,数组将被包装在一个 RpcResponse JSON 对象中。

每个对象包含:

Is this page helpful?