curl --request POST \
--url 'https://rpc-mainnet.solanatracker.io/?api_key=' \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getAccountInfo",
"params": [
"7xK1a6Ut1pCrH9CiMwdEqx7RyhqgUZRux692Sg4m1TTw",
{
"encoding": "base64",
"slot": 411108200
}
]
}
'{
"jsonrpc": "2.0",
"result": {
"context": {
"apiVersion": "4.2.1",
"slot": 411108200
},
"value": {
"data": [
"",
"base64"
],
"executable": false,
"lamports": 1523847120,
"owner": "11111111111111111111111111111111",
"rentEpoch": 18446744073709552000,
"space": 0
}
},
"id": 1
}历史余额
历史 getAccountInfo RPC 方法
读取 Solana 账户在任意过去 slot 的状态,或逐次查看账户更新。查看历史 getAccountInfo 的参数、限制和代码示例。
POST
/
curl --request POST \
--url 'https://rpc-mainnet.solanatracker.io/?api_key=' \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getAccountInfo",
"params": [
"7xK1a6Ut1pCrH9CiMwdEqx7RyhqgUZRux692Sg4m1TTw",
{
"encoding": "base64",
"slot": 411108200
}
]
}
'{
"jsonrpc": "2.0",
"result": {
"context": {
"apiVersion": "4.2.1",
"slot": 411108200
},
"value": {
"data": [
"",
"base64"
],
"executable": false,
"lamports": 1523847120,
"owner": "11111111111111111111111111111111",
"rentEpoch": 18446744073709552000,
"space": 0
}
},
"id": 1
}使用标准的 getAccountInfo 方法读取账户过去的状态。在配置对象中添加以下其中一项:
slot:账户在该 slot 结束时的状态。lastUpdateBeforeSlot:账户在该 slot 之前(不含)最后一次更新后的状态。firstUpdateAfterSlot:账户在该 slot 之后(不含)第一次更新后的状态。
getAccountInfo 返回账户的当前状态,见 getAccountInfo。
遍历账户历史
使用lastUpdateBeforeSlot 和 firstUpdateAfterSlot 时,context.slot 是返回的那次更新所在的 slot。把它传回请求,即可逐次遍历账户的历史。
添加 changes(1 到 20)可在 result.changes 中同时获得相应数量的更早版本,按从新到旧排列,每个版本包含 slot、blockTime 和 txnSignature。
限制
- 历史读取返回 finalized 数据。
commitment会被忽略,minContextSlot不能与这些选项同时使用。 - 账户在该时间点不存在或已关闭,或没有可用数据时,
value为null。 - SPL Token 和 Token-2022 的 mint 账户无法按历史读取:返回错误
-32033,data.reason为"splTokenMint"。Stake、vote、config 和 sysvar 账户也返回-32033。 - 代币账户根据其余额历史重建。会返回余额、mint、所有者和租金 lamports;不返回 Token-2022 扩展、委托人、冻结状态、关闭权限和精确的
space。 - 晚于最新可用 slot 的 slot 返回
-32030,早于最早可用 slot 的返回-32031,没有可用数据的 slot 返回-32034。lastUpdateBeforeSlot或firstUpdateAfterSlot遍历超过第一次或最后一次已知更新时返回-32020。 dataSlice不能与jsonParsed或jsonParsedEnhanced同时使用。
此页面对您有帮助吗?