← Articles
Solana IDL: fetch current and historical on-chain IDLs logo
solana

Solana IDL: fetch current and historical on-chain IDLs

· SEP 9, 2026 ·
Read
Share

CLI idl. Library fetchIdl / fetchAllHistories. Explorer idl.solana.com and idl-one.vercel.app. Publishing is a different package. Shipstern stays.

devrels.xyz/a/313

@solana/idl 0.2.0 fetches and reconstructs program IDLs from on-chain accounts. Anchor IDL accounts and the Solana Program Metadata Program (PMP). The headline is historical reconstruction: replay every on-chain write into a version timeline so an indexer or wallet can decode a transaction against the IDL that was live at that slot, not only the latest.

Publishing is out of scope. Write with npx @solana-program/program-metadata@latest write idl. This package reads what that wrote. @solana/security-txt is scaffolded and not published. Shipstern stays: Shipstern.

Library

Peer: @solana/kit. Node 20+. fetchIdl is PMP-first, then fndn fallback PMP, then Anchor. A fetch throws only if RPC fails. Data outcomes are ok, absent, or corrupt. fetchAllHistories returns PMP and Anchor snapshots side by side. Same shape as the HTTP API.

typescript
import { createSolanaRpc, address } from "@solana/kit"
import { fetchIdl, fetchAllHistories } from "@solana/idl"

const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com")
const programId = address("BUYuxRfhCMWavaUWxhGtPP3ksKEDZxCD5gzknk3JfAya")

const idl = await fetchIdl(rpc, programId)
const history = await fetchAllHistories(rpc, programId)

CLI

Binary idl. Four modes, mutually exclusive: bare IDL,--latest, --history, --buffer. History can pin --type pmp|anchor|both and dump with --dump-idls. Bare mode pretty-prints parsed JSON. Latest and history keep the on-chain bytes as a raw string so hashes stay stable.

bash
npx @solana/idl <program> --rpc https://api.mainnet-beta.solana.com
npx @solana/idl <program> --rpc https://api.mainnet-beta.solana.com --latest
npx @solana/idl <program> --rpc https://api.mainnet-beta.solana.com --history
npx @solana/idl <program> --history --type both --dump-idls ./idls
npx @solana/idl <buffer-address> --buffer

Explorer and API

Hosted UI: idl.solana.com and idl-one.vercel.app. Current, latest both, full history, plus on-chain security.txt (PMP-first, ELF fallback). Cluster: mainnet or devnet. Testnet is not supported. PMP is not deployed there.

GET /api/idl and GET /api/latest are quick reads. POST /api/history reconstructs every revision. Long histories: run the CLI against a private RPC.

Resources

Keep reading

Get new articles in your inbox

Technical deep-dives on Solana tooling, infrastructure, and ecosystem. No noise.