> ## Documentation Index
> Fetch the complete documentation index at: https://www.helius.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 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.

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](https://www.helius.dev/docs/vi/parsed-streams.md) 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ỳ `slot` nào từ phản hồi đến [Get IDL](https://www.helius.dev/docs/vi/api-reference/parsed-events/idl.md) để truy xuất tài liệu IDL của phiên bản đó. [Trình khám phá Orb](https://www.helius.dev/docs/vi/orb/explore-programs.md) 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 `instructions` củ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.** `404` có 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:

```javascript diff-idl-versions.js theme={"system"}
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)));
```

Để phát hiện các thay đổi theo thời gian, hãy lưu `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](https://www.helius.dev/docs/vi/billing/credits.md#sự-kiện-đã-phân-tích).

## 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. |

Các lỗi khác trả về nội dung JSON có thông báo `error`, chẳng hạn như `{"error": "no IDLs found for program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"}`.

## Tham số yêu cầu

**programId** `string` *required*

Địa chỉ chương trình, được mã hóa bằng base58.


## OpenAPI

````yaml vi/openapi/parsed-events.yaml GET /v1/parsed-events/idl/{programId}
openapi: 3.0.3
info:
  title: Sự kiện đã phân tích
  version: 0.1.0
  description: >-
    Phân tích cú pháp các giao dịch Solana và lịch sử giao dịch đã phân tích
    bằng Sự kiện đã phân tích.
servers:
  - url: https://mainnet.helius-rpc.com
security:
  - ApiKeyQuery: []
paths:
  /v1/parsed-events/idl/{programId}:
    get:
      tags:
        - Sự kiện đã phân tích
      summary: Liệt kê các phiên bản IDL
      description: >-
        Liệt kê mọi phiên bản IDL mà Sự kiện đã phân tích có cho một chương
        trình, từ cũ nhất đến mới nhất. Mỗi phiên bản được xác định bằng slot
        nơi phiên bản đó bắt đầu có hiệu lực.
      operationId: listIdlVersionsParsedEvents
      parameters:
        - $ref: '#/components/parameters/ProgramId'
      responses:
        '200':
          description: >-
            Các phiên bản IDL của chương trình, được sắp xếp theo `slot` tăng
            dần.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/IdlVersion'
              examples:
                default:
                  summary: Kamino Lend (3 phiên bản đầu tiên trong số 43 phiên bản)
                  value:
                    - slot: 182747476
                      sources:
                        - anchor
                    - slot: 205509752
                      sources:
                        - anchor
                    - slot: 206074074
                      sources:
                        - anchor
        '400':
          description: '`programId` không phải là một địa chỉ hợp lệ.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                default:
                  value:
                    error: 'invalid program id: notanaddress: String is the wrong size'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: >-
            Danh mục không có IDL cho chương trình này. Các chương trình mà Sự
            kiện đã phân tích giải mã bằng bộ giải mã tích hợp sẵn, chẳng hạn
            như SPL Token, sẽ trả về `404`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                default:
                  value:
                    error: >-
                      no IDLs found for program
                      TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
components:
  parameters:
    ProgramId:
      name: programId
      in: path
      required: true
      description: Địa chỉ chương trình, được mã hóa bằng base58.
      schema:
        type: string
        example: KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD
  schemas:
    IdlVersion:
      type: object
      description: Một phiên bản IDL của chương trình.
      required:
        - slot
        - sources
      properties:
        slot:
          type: integer
          format: uint64
          description: >-
            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.
        sources:
          type: array
          description: >-
            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.
          items:
            type: string
    ErrorResponse:
      type: object
      description: Phản hồi lỗi ở cấp yêu cầu.
      properties:
        error:
          type: string
          description: Thông báo lỗi.
  responses:
    Unauthorized:
      description: >-
        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.
      content:
        text/plain:
          schema:
            type: string
          examples:
            default:
              value: Unauthorized
  securitySchemes:
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api-key

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.