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

# IDL 檔案

> Raydium 各程式的版本化 Anchor IDL 檔案，依程式發佈版本歸檔，讓你可以解碼任何時期的交易，並將客戶端固定在其建置時所依據的確切介面。

> [!NOTE]
>
> **本頁內容由 AI 自動翻譯，所有內容以英文版本為準。**
>
> [查看英文版 →](https://docs.raydium.io/reference/idl/index.md)

> [!NOTE]
>
> 本章是 Raydium 發佈 Anchor IDL 檔案的唯一位置。涵蓋 **CPMM**、**CLMM** 和 **LaunchLab**。AMM v4、Stable AMM、AMM 路由和農場程式不是 Anchor 程式，沒有 IDL。它們的佈局位於 SDK 中，請參閱 [`sdk-api/anchor-idl`](https://docs.raydium.io/zh-Hant/sdk-api/anchor-idl)。

## 各程式的最新 IDL

| 程式 | 最新歸檔版本 | IDL | TS 型別 | 狀態 | 所有版本 |
| - | - | - | - | - | - |
| **LaunchLab** | 2026-12-07 | [`raydium_launchpad.json`](https://raydium-io.github.io/raydium-docs-v1/idl/launchlab/2026-12-07/raydium_launchpad.json) | [`raydium_launchpad.ts`](https://raydium-io.github.io/raydium-docs-v1/idl/launchlab/2026-12-07/raydium_launchpad.ts) | 自 2026-12-07 13:00 UTC 起生效 | [LaunchLab →](https://docs.raydium.io/zh-Hant/reference/idl/launchlab.md) |
| **CPMM** | 2026-10-30 | [`raydium_cp_swap.json`](https://raydium-io.github.io/raydium-docs-v1/idl/cpmm/2026-10-30/raydium_cp_swap.json) | [`raydium_cp_swap.ts`](https://raydium-io.github.io/raydium-docs-v1/idl/cpmm/2026-10-30/raydium_cp_swap.ts) | 自 2026-10-30 起生效 | [CPMM →](https://docs.raydium.io/zh-Hant/reference/idl/cpmm.md) |
| **CLMM** | 2026-10-22 | [`raydium_clmm.json`](https://raydium-io.github.io/raydium-docs-v1/idl/clmm/2026-10-22/raydium_clmm.json) | [`raydium_clmm.ts`](https://raydium-io.github.io/raydium-docs-v1/idl/clmm/2026-10-22/raydium_clmm.ts) | 自 2026-10-22 起生效 | [CLMM →](https://docs.raydium.io/zh-Hant/reference/idl/clmm.md) |

每個程式頁面保留完整的版本歷程。自 2026-05 以來在[更新日誌](https://docs.raydium.io/zh-Hant/reference/changelog.md)中記錄的每個發佈版本，在那裡都有其專屬的 IDL。

## 如何選擇版本

1. **建置新的客戶端：** 使用狀態為生效中的最新版本，並在建置時固定該版本的目錄。
2. **解碼歷史交易：** 開啟該程式的頁面，選擇**主網期間**涵蓋交易區塊時間的版本。來自其他期間的 IDL 可能錯誤解碼指令資料、帳戶，以及最重要的是錯誤代碼 — Anchor 按位置對錯誤代碼編號。
3. **審查升級：** 每個版本的詳細資訊列出與前一版本相比的變更，並連結到說明原因的更新日誌條目。

## 檔案的發佈方式

* **位置。** 檔案是靜態資產，位於 `https://raydium-io.github.io/raydium-docs-v1/idl/<program>/<version>/`。`<program>` 是 `launchlab`、`cpmm` 或 `clmm`。`<version>` 是一個日期：IDL 所屬的程式發佈版本。對於沒有更新日誌條目的發佈，它是原始碼提交的日期。對於從前 `raydium-idl` 儲存庫匯入的快照，它是該快照的日期。
* **每個版本兩個檔案。** `<name>.json` 是 Anchor IDL（規格 `0.1.0`）。`<name>.ts` 是由 JSON 生成、對應 `@anchor-lang/core` 的 `Program<T>` 的 TypeScript 型別。
* **不可變。** 已發佈的檔案永遠不會被編輯或刪除。新的程式發佈會新增一個新的 `<version>` 目錄。因此，舊更新日誌條目中的連結會持續解析到它所描述的 IDL。
* **校驗和。** 每個版本都列出兩個檔案的 SHA-256。在依賴下載的檔案之前先進行驗證：

```bash theme={null}
curl -sO https://raydium-io.github.io/raydium-docs-v1/idl/launchlab/2026-12-07/raydium_launchpad.json
sha256sum raydium_launchpad.json
```

* **來源。** 每個版本記錄其來源：生成它的程式原始碼提交和 Anchor CLI，或它匯入自的快照。新版本使用 `anchor idl build` 從已發佈的原始碼生成，而不是從鏈上取得。即使鏈上 IDL 帳戶尚未重新整理，它們也與已發佈的程式碼相符。

## 使用歸檔的 IDL

```ts theme={null}
// @anchor-lang/core 1.0.2 — LaunchLab IDL from the 2026-12-07 release
import { Program, AnchorProvider } from "@anchor-lang/core";
import launchlabIdl from "./idls/launchlab-2026-12-07/raydium_launchpad.json";
import type { RaydiumLaunchpad } from "./idls/launchlab-2026-12-07/raydium_launchpad";

const provider = new AnchorProvider(connection, wallet, {});
// The IDL carries the program id in `idl.address`, so the two-argument form is correct.
const program = new Program<RaydiumLaunchpad>(launchlabIdl as RaydiumLaunchpad, provider);
```

將檔案納入你的專案，而不是在執行階段取得它們。固定 `<version>` 目錄，這樣升級永遠不會悄悄改變你的解碼器。

## 與 SDK 及鏈上 IDL 的關係

* **SDK。** 如果你透過 `@raydium-io/raydium-sdk-v2` 建置交易，你不需要這些檔案。它自帶佈局和建置器。此歸檔適用於從 IDL 生成客戶端、解碼程式日誌和事件，或審計升級的整合者。
* **鏈上 IDL。** `anchor idl fetch` 只會傳回其帳戶持有的最新 IDL，而該帳戶可能落後於程式升級。請參閱[每個程式保留它的位置](https://docs.raydium.io/zh-Hant/sdk-api/anchor-idl.md#where-to-find-them)。當兩者不一致時，對相符的發佈版本信任歸檔檔案。


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