历史账户
getHistoricalAccountInfo
读取任意 Solana 账户在过去某个槽位或特定交易刚执行后的状态,支持 getAccountInfo 编码,并返回最后一次写入的位置。
POST
/
getHistoricalAccountInfo
curl --request POST \
--url 'https://mainnet.helius-rpc.com/?api-key=' \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"id": "1",
"method": "getHistoricalAccountInfo",
"params": [
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
{
"slot": 445000000
},
{
"encoding": "jsonParsed"
}
]
}
'import requests
url = "https://mainnet.helius-rpc.com/?api-key="
payload = {
"jsonrpc": "2.0",
"id": "1",
"method": "getHistoricalAccountInfo",
"params": ["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", { "slot": 445000000 }, { "encoding": "jsonParsed" }]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
jsonrpc: '2.0',
id: '1',
method: 'getHistoricalAccountInfo',
params: [
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
{slot: 445000000},
{encoding: 'jsonParsed'}
]
})
};
fetch('https://mainnet.helius-rpc.com/?api-key=', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://mainnet.helius-rpc.com/?api-key=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'jsonrpc' => '2.0',
'id' => '1',
'method' => 'getHistoricalAccountInfo',
'params' => [
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
[
'slot' => 445000000
],
[
'encoding' => 'jsonParsed'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://mainnet.helius-rpc.com/?api-key="
payload := strings.NewReader("{\n \"jsonrpc\": \"2.0\",\n \"id\": \"1\",\n \"method\": \"getHistoricalAccountInfo\",\n \"params\": [\n \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\",\n {\n \"slot\": 445000000\n },\n {\n \"encoding\": \"jsonParsed\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://mainnet.helius-rpc.com/?api-key=")
.header("Content-Type", "application/json")
.body("{\n \"jsonrpc\": \"2.0\",\n \"id\": \"1\",\n \"method\": \"getHistoricalAccountInfo\",\n \"params\": [\n \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\",\n {\n \"slot\": 445000000\n },\n {\n \"encoding\": \"jsonParsed\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://mainnet.helius-rpc.com/?api-key=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"jsonrpc\": \"2.0\",\n \"id\": \"1\",\n \"method\": \"getHistoricalAccountInfo\",\n \"params\": [\n \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\",\n {\n \"slot\": 445000000\n },\n {\n \"encoding\": \"jsonParsed\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"jsonrpc": "2.0",
"id": "1",
"result": {
"context": {
"slot": 468129571
},
"value": {
"lamports": 531589475273,
"owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"data": [
"<string>"
],
"executable": false,
"rentEpoch": 123,
"space": 82,
"lastUpdatedAt": {
"slot": 444999837,
"transactionIndex": 700
}
}
}
}{
"jsonrpc": "2.0",
"error": {
"code": -32602,
"message": "参数无效"
},
"id": "1"
}{
"jsonrpc": "2.0",
"error": {
"code": -32001,
"message": "未授权"
},
"id": "1"
}{
"jsonrpc": "2.0",
"error": {
"code": -32005,
"message": "请求过多"
},
"id": "1"
}{
"jsonrpc": "2.0",
"error": {
"code": -32603,
"message": "内部错误"
},
"id": "1"
}{
"jsonrpc": "2.0",
"error": {
"code": -32002,
"message": "服务不可用"
},
"id": "1"
}{
"jsonrpc": "2.0",
"error": {
"code": -32003,
"message": "网关超时"
},
"id": "1"
}getHistoricalAccountInfo 处于 Beta 阶段。参数、定价、响应格式和数据覆盖范围可能会发生变化。概述
getHistoricalAccountInfo 返回 Solana 账户在过去某个槽位或该槽位中特定交易刚执行后的状态。这是 Helius 独有的 RPC 方法。标准的 getAccountInfo 仅返回当前状态。
响应包含与 getAccountInfo 相同的账户字段,并额外包含 lastUpdatedAt:最后一次写入所返回状态的槽位和交易。
历史数据从槽位 444,959,999(2026 年 9 月 7 日)起可用,即纪元 1030 开始时的状态。请求更早的槽位会返回错误 -32018。
getHistoricalAccountInfo 在主网上面向 Business 及更高级别的套餐提供,Beta 期间每次调用消耗 0 个积分。定价可能会发生变化。
选择历史位置
第二个参数是一个查询对象,用于选择要读取的历史时间点:| 查询 | 返回的账户状态 |
|---|---|
省略或 {} | 最新已索引槽位的状态,上限为所请求的确认级别 |
{ "slot": 445000000 } | 槽位 445,000,000 结束时的状态 |
{ "slot": 445000000, "transactionIndex": 10 } | 槽位 445,000,000 中索引为 10 的交易刚执行后的状态 |
transactionIndex 要求提供 slot。要读取索引为 N 的交易执行前的账户状态,请查询 transactionIndex: N - 1。对于槽位中的第一笔交易,请查询前一个槽位,并且不要提供 transactionIndex。
纪元奖励等非交易写入会在槽位结束时应用。包含 transactionIndex 的查询绝不会包含这些写入。
请求示例
curl https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "getHistoricalAccountInfo",
"params": [
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
{ "slot": 445000000 },
{ "encoding": "jsonParsed" }
]
}'
解读响应
value是账户在所请求位置的状态;如果账户当时不存在,则为null:账户尚未创建或已关闭。值为null的响应不包含lastUpdatedAt。lastUpdatedAt.slot和lastUpdatedAt.transactionIndex标识产生此状态的写入。该写入发生在你请求的位置或之前。- 当写入发生在交易之外(例如纪元奖励)时,
lastUpdatedAt.transactionIndex为null。 lastUpdatedAt.slot为 444,959,999 且transactionIndex为null,表示自历史数据覆盖开始以来,该账户未发生变化。这并不表示账户是在该槽位写入的。context.slot是 Helius 处理请求时已索引的最新槽位,而不是你查询的槽位。jsonParsed代币账户使用铸币在所请求位置的小数位数。如果无法读取该位置的铸币,账户将回退到 base64。
lastUpdatedAt 作为游标。请参阅回溯账户历史记录。
错误
| 代码 | 含义 |
|---|---|
-32018 | 该槽位早于历史数据覆盖的起点(槽位 444,959,999) |
-32004 | 该槽位比所请求的确认级别允许的槽位更新。请使用 confirmed 或查询更早的槽位 |
-32602 | 参数无效,例如提供 transactionIndex 但未提供 slot、使用 base58 编码,或包含未知的配置字段 |
-32601 | 找不到方法。请调用你的 Helius 主网或 Gatekeeper 端点;该方法在开发网上不可用 |
相关方法
Historical Accounts Guide
了解历史账户方法的位置、覆盖范围和 lastUpdatedAt 的工作原理
getHistoricalTokenAccountsByOwner
列出钱包在过去某个槽位的代币账户
getTransactionsForAddress
查找你要检查的交易对应的槽位和 transactionIndex
getAccountInfo
读取账户的当前状态
请求参数
授权
你的 Helius API 密钥。你可以在控制面板中免费获取。
请求体
application/json
此页面对您有帮助吗?
⌘I
getHistoricalAccountInfo
curl --request POST \
--url 'https://mainnet.helius-rpc.com/?api-key=' \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"id": "1",
"method": "getHistoricalAccountInfo",
"params": [
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
{
"slot": 445000000
},
{
"encoding": "jsonParsed"
}
]
}
'import requests
url = "https://mainnet.helius-rpc.com/?api-key="
payload = {
"jsonrpc": "2.0",
"id": "1",
"method": "getHistoricalAccountInfo",
"params": ["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", { "slot": 445000000 }, { "encoding": "jsonParsed" }]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
jsonrpc: '2.0',
id: '1',
method: 'getHistoricalAccountInfo',
params: [
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
{slot: 445000000},
{encoding: 'jsonParsed'}
]
})
};
fetch('https://mainnet.helius-rpc.com/?api-key=', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://mainnet.helius-rpc.com/?api-key=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'jsonrpc' => '2.0',
'id' => '1',
'method' => 'getHistoricalAccountInfo',
'params' => [
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
[
'slot' => 445000000
],
[
'encoding' => 'jsonParsed'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://mainnet.helius-rpc.com/?api-key="
payload := strings.NewReader("{\n \"jsonrpc\": \"2.0\",\n \"id\": \"1\",\n \"method\": \"getHistoricalAccountInfo\",\n \"params\": [\n \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\",\n {\n \"slot\": 445000000\n },\n {\n \"encoding\": \"jsonParsed\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://mainnet.helius-rpc.com/?api-key=")
.header("Content-Type", "application/json")
.body("{\n \"jsonrpc\": \"2.0\",\n \"id\": \"1\",\n \"method\": \"getHistoricalAccountInfo\",\n \"params\": [\n \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\",\n {\n \"slot\": 445000000\n },\n {\n \"encoding\": \"jsonParsed\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://mainnet.helius-rpc.com/?api-key=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"jsonrpc\": \"2.0\",\n \"id\": \"1\",\n \"method\": \"getHistoricalAccountInfo\",\n \"params\": [\n \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\",\n {\n \"slot\": 445000000\n },\n {\n \"encoding\": \"jsonParsed\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"jsonrpc": "2.0",
"id": "1",
"result": {
"context": {
"slot": 468129571
},
"value": {
"lamports": 531589475273,
"owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"data": [
"<string>"
],
"executable": false,
"rentEpoch": 123,
"space": 82,
"lastUpdatedAt": {
"slot": 444999837,
"transactionIndex": 700
}
}
}
}{
"jsonrpc": "2.0",
"error": {
"code": -32602,
"message": "参数无效"
},
"id": "1"
}{
"jsonrpc": "2.0",
"error": {
"code": -32001,
"message": "未授权"
},
"id": "1"
}{
"jsonrpc": "2.0",
"error": {
"code": -32005,
"message": "请求过多"
},
"id": "1"
}{
"jsonrpc": "2.0",
"error": {
"code": -32603,
"message": "内部错误"
},
"id": "1"
}{
"jsonrpc": "2.0",
"error": {
"code": -32002,
"message": "服务不可用"
},
"id": "1"
}{
"jsonrpc": "2.0",
"error": {
"code": -32003,
"message": "网关超时"
},
"id": "1"
}