getMultipleAccounts
getMultipleAccounts
方法返回一组公钥的账号信息。
请求参数
<array>
- An array of Pubkeys to query, as base-58 encoded strings<object>
- (可选) Configuration object containing the following optional fields:- (可选) Commitment
- encoding:
<string>
- encoding for Account data, either "base58" (slow), "base64", "base64+zstd", or "jsonParsed". "base58" is limited to Account data of less than 129 bytes. "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. - (可选) dataSlice:
<object>
- limit the returned account data using the provided offset:and length: fields; only available for "base58", "base64" or "base64+zstd" encodings.
返回结果
结果为RpcResponse对象数组,成员可能是:
<null>
- 如果公钥账号不存在则返回此值<object>
- 否则返回一个JSON对象包含如下字段:- lamports:
, number of lamports assigned to this account, as a u64 - owner:
, 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 {
: }, depending on encoding parameter - executable:
, boolean indicating if the account contains a program (and is strictly read-only) - rentEpoch:
, the epoch at which this account will next owe rent, as u64
- lamports:
示例代码
请求:
curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getMultipleAccounts",
"params": [
[
"vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg",
"4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA"
],
{
"dataSlice": {
"offset": 0,
"length": 0
}
}
]
}
响应:
{
"jsonrpc": "2.0",
"result": {
"context": {
"slot": 1
},
"value": [
{
"data": [
"AAAAAAEAAAACtzNsyJrW0g==",
"base64"
],
"executable": false,
"lamports": 1000000000,
"owner": "11111111111111111111111111111111",
"rentEpoch": 2
},
{
"data": [
"",
"base64"
],
"executable": false,
"lamports": 5000000000,
"owner": "11111111111111111111111111111111",
"rentEpoch": 2
}
]
},
"id": 1
}
请求:
curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getMultipleAccounts",
"params": [
[
"vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg",
"4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA"
],
{
"encoding": "base58"
}
]
}
响应:
{
"jsonrpc": "2.0",
"result": {
"context": {
"slot": 1
},
"value": [
{
"data": [
"11116bv5nS2h3y12kD1yUKeMZvGcKLSjQgX6BeV7u1FrjeJcKfsHRTPuR3oZ1EioKtYGiYxpxMG5vpbZLsbcBYBEmZZcMKaSoGx9JZeAuWf",
"base58"
],
"executable": false,
"lamports": 1000000000,
"owner": "11111111111111111111111111111111",
"rentEpoch": 2
},
{
"data": [
"",
"base58"
],
"executable": false,
"lamports": 5000000000,
"owner": "11111111111111111111111111111111",
"rentEpoch": 2
}
]
},
"id": 1
}