Tài khoản lịch sử
getHistoricalAccountInfo
Đọc bất kỳ tài khoản Solana nào tại một slot trong quá khứ hoặc ngay sau một giao dịch cụ thể, với các kiểu mã hóa của getAccountInfo và vị trí của lần ghi gần nhất.
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": "Tham số không hợp lệ"
},
"id": "1"
}{
"jsonrpc": "2.0",
"error": {
"code": -32001,
"message": "Không được phép"
},
"id": "1"
}{
"jsonrpc": "2.0",
"error": {
"code": -32005,
"message": "Quá nhiều yêu cầu"
},
"id": "1"
}{
"jsonrpc": "2.0",
"error": {
"code": -32603,
"message": "Lỗi nội bộ"
},
"id": "1"
}{
"jsonrpc": "2.0",
"error": {
"code": -32002,
"message": "Dịch vụ không khả dụng"
},
"id": "1"
}{
"jsonrpc": "2.0",
"error": {
"code": -32003,
"message": "Hết thời gian chờ cổng kết nối"
},
"id": "1"
}getHistoricalAccountInfo đang ở giai đoạn Beta. Các tham số, mức giá, định dạng phản hồi và phạm vi dữ liệu có thể thay đổi.Tổng quan
getHistoricalAccountInfo trả về một tài khoản Solana tại một slot trong quá khứ hoặc ngay sau một giao dịch cụ thể trong slot đó. Đây là phương thức RPC độc quyền của Helius. getAccountInfo tiêu chuẩn chỉ trả về trạng thái hiện tại.
Phản hồi có các trường tài khoản giống như getAccountInfo, cộng thêm lastUpdatedAt: slot và giao dịch đã ghi lần gần nhất trạng thái mà bạn nhận được.
Dữ liệu lịch sử có từ slot 444,959,999 (ngày 7 tháng 9 năm 2026) trở đi, tương ứng với trạng thái tại thời điểm bắt đầu epoch 1030. Các yêu cầu cho những slot trước đó trả về lỗi -32018.
getHistoricalAccountInfo khả dụng trên mainnet đối với gói Business trở lên và có chi phí 0 credit cho mỗi lần gọi trong giai đoạn beta. Mức giá có thể thay đổi.
Chọn một vị trí trong lịch sử
Tham số thứ hai là một đối tượng truy vấn dùng để chọn thời điểm cần đọc trong lịch sử:| Truy vấn | Tài khoản được trả về |
|---|---|
Bỏ qua hoặc {} | Tại slot mới nhất đã được lập chỉ mục, giới hạn theo mức commitment được yêu cầu |
{ "slot": 445000000 } | Tại cuối slot 445,000,000 |
{ "slot": 445000000, "transactionIndex": 10 } | Ngay sau khi giao dịch ở chỉ mục 10 trong slot 445,000,000 được thực thi |
transactionIndex yêu cầu slot. Để đọc một tài khoản ngay trước giao dịch tại chỉ mục N, hãy truy vấn transactionIndex: N - 1. Đối với giao dịch đầu tiên trong một slot, hãy truy vấn slot trước đó mà không có transactionIndex.
Các thao tác ghi không thuộc giao dịch, chẳng hạn như phần thưởng epoch, được áp dụng ở cuối slot. Truy vấn có transactionIndex không bao giờ bao gồm các thao tác này.
Ví dụ về yêu cầu
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" }
]
}'
Đọc phản hồi
valuelà tài khoản tại vị trí được yêu cầu, hoặcnullnếu tài khoản chưa tồn tại vào thời điểm đó: tài khoản chưa được tạo hoặc đã bị đóng. Phản hồinullkhông cólastUpdatedAt.lastUpdatedAt.slotvàlastUpdatedAt.transactionIndexxác định thao tác ghi đã tạo ra trạng thái này. Thao tác ghi diễn ra tại hoặc trước vị trí bạn yêu cầu.lastUpdatedAt.transactionIndexlànullkhi thao tác ghi diễn ra bên ngoài một giao dịch, chẳng hạn như phần thưởng epoch.lastUpdatedAt.slotbằng 444,959,999 vớitransactionIndexlànullnghĩa là tài khoản chưa thay đổi kể từ khi phạm vi dữ liệu lịch sử bắt đầu. Điều này không có nghĩa là tài khoản đã được ghi trong slot đó.context.slotlà slot mới nhất mà Helius đã lập chỉ mục khi xử lý yêu cầu, không phải slot bạn đã truy vấn.- Tài khoản token
jsonParsedsử dụng số chữ số thập phân của mint tại vị trí được yêu cầu. Nếu không thể đọc mint tại vị trí đó, tài khoản sẽ chuyển sang dùng base64.
lastUpdatedAt làm con trỏ. Xem Duyệt ngược lịch sử tài khoản.
Lỗi
| Mã | Ý nghĩa |
|---|---|
-32018 | Slot nằm trước thời điểm bắt đầu phạm vi dữ liệu lịch sử (slot 444,959,999) |
-32004 | Slot mới hơn mức commitment được yêu cầu cho phép. Hãy dùng confirmed hoặc truy vấn một slot cũ hơn |
-32602 | Tham số không hợp lệ, chẳng hạn như transactionIndex không có slot, kiểu mã hóa base58 hoặc trường cấu hình không xác định |
-32601 | Không tìm thấy phương thức. Hãy gọi endpoint mainnet hoặc Gatekeeper của Helius; phương thức này không khả dụng trên devnet |
Phương thức liên quan
Historical Accounts Guide
Cách vị trí, phạm vi dữ liệu và lastUpdatedAt hoạt động đối với các phương thức tài khoản lịch sử
getHistoricalTokenAccountsByOwner
Liệt kê các tài khoản token của một ví tại một slot trong quá khứ
getTransactionsForAddress
Tìm slot và transactionIndex của các giao dịch bạn muốn kiểm tra
getAccountInfo
Đọc trạng thái hiện tại của một tài khoản
Tham số yêu cầu
Slot cần đọc trạng thái. Trả về tài khoản tại thời điểm kết thúc slot này. Slot sớm nhất được hỗ trợ là 444959999, tương ứng với trạng thái tại thời điểm bắt đầu epoch 1030. Khi bị bỏ qua, hệ thống đọc slot mới nhất đã được lập chỉ mục, giới hạn theo mức commitment được yêu cầu.
Vị trí của một giao dịch trong slot. Trả về trạng thái tài khoản ngay sau khi giao dịch đó được thực thi, thay vì ở cuối slot. Yêu cầu slot.
Định dạng mã hóa cho dữ liệu tài khoản. base58 và binary không được hỗ trợ.
base64base64+zstdjsonParsed
Ủy quyền
Khóa API Helius của bạn. Bạn có thể nhận khóa miễn phí trong bảng điều khiển.
Nội dung
application/json
Mảng chứa địa chỉ tài khoản, một đối tượng truy vấn tùy chọn dùng để chọn vị trí trong lịch sử và một đối tượng cấu hình tùy chọn.
Required array length:
1 - 3 elementsĐịa chỉ được mã hóa Base-58 của tài khoản cần đọc.
Ví dụ:
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
Trang này có hữu ích không?
⌘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": "Tham số không hợp lệ"
},
"id": "1"
}{
"jsonrpc": "2.0",
"error": {
"code": -32001,
"message": "Không được phép"
},
"id": "1"
}{
"jsonrpc": "2.0",
"error": {
"code": -32005,
"message": "Quá nhiều yêu cầu"
},
"id": "1"
}{
"jsonrpc": "2.0",
"error": {
"code": -32603,
"message": "Lỗi nội bộ"
},
"id": "1"
}{
"jsonrpc": "2.0",
"error": {
"code": -32002,
"message": "Dịch vụ không khả dụng"
},
"id": "1"
}{
"jsonrpc": "2.0",
"error": {
"code": -32003,
"message": "Hết thời gian chờ cổng kết nối"
},
"id": "1"
}