Sự kiện đã phân tích
Liệt kê các phiên bản IDL
Liệt kê mọi phiên bản IDL mà Parsed Events có cho một chương trình Solana, cùng với slot mà mỗi phiên bản bắt đầu có hiệu lực.
GET
/
v1
/
parsed-events
/
idl
/
{programId}
Liệt kê các phiên bản IDL
curl --request GET \
--url 'https://mainnet.helius-rpc.com/v1/parsed-events/idl/{programId}?api-key='import requests
url = "https://mainnet.helius-rpc.com/v1/parsed-events/idl/{programId}?api-key="
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://mainnet.helius-rpc.com/v1/parsed-events/idl/{programId}?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/v1/parsed-events/idl/{programId}?api-key=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://mainnet.helius-rpc.com/v1/parsed-events/idl/{programId}?api-key="
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://mainnet.helius-rpc.com/v1/parsed-events/idl/{programId}?api-key=")
.asString();require 'uri'
require 'net/http'
url = URI("https://mainnet.helius-rpc.com/v1/parsed-events/idl/{programId}?api-key=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body[
{
"slot": 182747476,
"sources": [
"anchor"
]
},
{
"slot": 205509752,
"sources": [
"anchor"
]
},
{
"slot": 206074074,
"sources": [
"anchor"
]
}
]{
"error": "invalid program id: notanaddress: String is the wrong size"
}Unauthorized{
"error": "no IDLs found for program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
}Các tham số đường dẫn, lược đồ phản hồi và ví dụ trên trang này được tạo từ định nghĩa OpenAPI.
List IDL Versions trả về lịch sử giao diện của một chương trình từ danh mục IDL mà Parsed Events và Parsed Streams sử dụng để giải mã các lệnh. Mỗi mục là một phiên bản, được xác định bằng slot mà phiên bản đó bắt đầu có hiệu lực. Các mục được sắp xếp từ cũ nhất đến mới nhất, vì vậy mục cuối cùng là phiên bản hiện tại.
Truyền bất kỳ
Để phát hiện các thay đổi theo thời gian, hãy lưu
Các lỗi khác trả về nội dung JSON có thông báo
slot nào từ phản hồi đến Get IDL để truy xuất tài liệu IDL của phiên bản đó. Trình khám phá Orb sử dụng các endpoint này để hiển thị IDL của chương trình.
Trường hợp sử dụng
- Theo dõi các thay đổi giao diện. Thăm dò List IDL Versions cho chương trình mà bạn phụ thuộc vào. Khi một phiên bản mới xuất hiện, hãy truy xuất phiên bản đó và phiên bản trước bằng Get IDL, rồi so sánh
instructionscủa chúng. Một lệnh quản trị hoặc lệnh cấp quyền mới cần được xem xét về bảo mật. - Kiểm tra mức độ bao phủ của danh mục.
404có nghĩa là danh mục không có IDL cho chương trình. Thay vào đó, các chương trình như SPL Token được giải mã bằng bộ giải mã tích hợp và cũng trả về404.
Ví dụ: Phát hiện phiên bản IDL mới
Tập lệnh này liệt kê các phiên bản IDL của một chương trình, truy xuất hai phiên bản mới nhất và in ra các lệnh đã được thêm hoặc xóa:diff-idl-versions.js
const API_KEY = process.env.HELIUS_API_KEY;
if (!API_KEY) {
console.error("Missing HELIUS_API_KEY.");
process.exit(1);
}
const BASE = "https://mainnet.helius-rpc.com/v1/parsed-events/idl";
const PROGRAM_ID = "KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD";
async function get(path) {
const response = await fetch(`${BASE}/${path}?api-key=${API_KEY}`);
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${await response.text()}`);
}
return response.json();
}
const versions = await get(PROGRAM_ID);
if (versions.length < 2) {
console.log("Fewer than two IDL versions; nothing to compare.");
process.exit(0);
}
const [previous, latest] = versions.slice(-2);
const [before, after] = await Promise.all([
get(`${PROGRAM_ID}/${previous.slot}`),
get(`${PROGRAM_ID}/${latest.slot}`),
]);
const names = (idl) => new Set(idl.instructions.map((ix) => ix.name));
const beforeNames = names(before);
const afterNames = names(after);
console.log(`Comparing slot ${previous.slot} with slot ${latest.slot}`);
console.log("Added:", [...afterNames].filter((name) => !beforeNames.has(name)));
console.log("Removed:", [...beforeNames].filter((name) => !afterNames.has(name)));
slot của phiên bản cuối cùng bạn đã thấy và so sánh với giá trị đó sau mỗi lần thăm dò.
Credit
Mỗi yêu cầu tốn 10 credit và khả dụng trên tất cả các gói. Ví dụ trên thực hiện ba yêu cầu, vì vậy tốn 30 credit. Xem Credit.Lỗi
| Trạng thái | Khi nào xảy ra |
|---|---|
400 | programId không phải là địa chỉ base58 hợp lệ. |
401 | Khóa API bị thiếu hoặc không hợp lệ. Nội dung phản hồi là văn bản thuần túy: Unauthorized. |
404 | Danh mục không có IDL cho chương trình. |
error, chẳng hạn như {"error": "no IDLs found for program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"}.
Tham số yêu cầu
string
bắt buộc
Địa chỉ chương trình, được mã hóa bằng base58.
Ủy quyền
Tham số đường dẫn
Địa chỉ chương trình, được mã hóa bằng base58.
Ví dụ:
"KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD"
Phản hồi
Các phiên bản IDL của chương trình, được sắp xếp theo slot tăng dần.
Slot nơi phiên bản IDL này bắt đầu có hiệu lực. Truyền giá trị này cho Lấy IDL để truy xuất phiên bản này.
Nơi Sự kiện đã phân tích tìm thấy phiên bản này. Các giá trị bao gồm anchor, program_metadata và github; có thể sẽ có thêm các giá trị khác. Một phiên bản có thể có nhiều nguồn.
Trang này có hữu ích không?
⌘I
Liệt kê các phiên bản IDL
curl --request GET \
--url 'https://mainnet.helius-rpc.com/v1/parsed-events/idl/{programId}?api-key='import requests
url = "https://mainnet.helius-rpc.com/v1/parsed-events/idl/{programId}?api-key="
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://mainnet.helius-rpc.com/v1/parsed-events/idl/{programId}?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/v1/parsed-events/idl/{programId}?api-key=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://mainnet.helius-rpc.com/v1/parsed-events/idl/{programId}?api-key="
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://mainnet.helius-rpc.com/v1/parsed-events/idl/{programId}?api-key=")
.asString();require 'uri'
require 'net/http'
url = URI("https://mainnet.helius-rpc.com/v1/parsed-events/idl/{programId}?api-key=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body[
{
"slot": 182747476,
"sources": [
"anchor"
]
},
{
"slot": 205509752,
"sources": [
"anchor"
]
},
{
"slot": 206074074,
"sources": [
"anchor"
]
}
]{
"error": "invalid program id: notanaddress: String is the wrong size"
}Unauthorized{
"error": "no IDLs found for program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
}