Learn · Updated November 18, 2026

Reading a program's IDL so you can decode it

An Anchor IDL is a JSON description of a program: every instruction with its discriminator, arguments and ordered accounts, plus the types and events those use. A decoder reads it to turn raw instruction bytes into named values. It can live on chain, in a repository or in a package, and an out-of-date copy decodes wrongly.

Where IDLs live#

There are three common places, and a program may use any of them.

On chain, in Anchor's IDL account. Anchor can publish the IDL to an account whose address is derived from the program: create_with_seed of the program's signer address, the seed anchor:idl, and the program ID. The account holds an authority, a length and the IDL as zlib-compressed JSON. The upgrade authority writes it, so it tends to track deployed code, but only if someone remembers to update it.

On chain, in the Program Metadata program. ProgM6JCCvbYkfKqJYHePx4xxSUSqJp7rh8Lyv7nk7S stores metadata for any program in accounts derived from the program and a seed such as idl. Accounts written by the upgrade authority are canonical; anyone else may attach a third-party one, which you should treat with less trust.

Off chain. Teams publish IDLs in their GitHub repositories and inside SDK packages. These are easy to fetch and pin by commit or version, and they go stale when nobody regenerates them after an upgrade.

Where we found eight real IDLs#

We fetched the IDLs for the programs our docs decode on 18 November 2026, then checked each against real mainnet instructions: every decoded instruction name had to match the "Instruction:" line the program itself logged.

ProgramWhere the usable IDL wasWhat we noticed
Pump.fun, PumpSwapthe team's public docs repositorycurrent; some real calls omit the newest trailing arguments
Raydium CPMM, CLMMRaydium's IDL repositorycurrent
Orca Whirlpoolinside the SDK package, version 0.22.0the repository points to the package for the latest IDL
Meteora DLMM, DAMM v2each SDK repositorycurrent
Jupiter v6the on-chain IDL accountthe copy in Jupiter's CPI repository lacks route_v2 and newer swap variants
Raydium AMM v4none: not an Anchor programlayouts come from its Rust source

The lesson in the last two rows is the one to keep: a repository IDL can lag the program by a long way, and some programs have no IDL at all.

Instructions and their arguments#

Each entry in instructions gives a name, an ordered list of args with a type each, and in IDLs from Anchor 0.30 onward an explicit discriminator. The arguments follow the discriminator in the instruction data, in exactly the listed order, encoded in Borsh. Read the discriminator from the IDL when it is there: since Anchor 0.31 a program may set its own instead of the name hash. The Anchor discriminator page explains both.

Account order#

The accounts list of an instruction is the contract for its account indexes. The first account in the list is the first index in the instruction, the second is the second, and so on, which is how you learn that index 3 is the bonding curve or the pool. Entries also say whether an account must sign or be writable, and some are optional or grouped. Optional accounts are where decoders slip: check how the program marks an omitted one before you assume every slot is filled.

Types and events#

The types section defines every struct and enum the arguments and accounts use, with fields in order. Enum variants are matched by position, so the order in the IDL is part of the format. The events section lists the events the program emits, and accounts at the top level lists its account structs. A shred decoder needs types for nearly everything, events only once it has execution data, and account types only if it fetches account state.

Codama and other formats#

Codama is a separate, standardised IDL format for describing Solana programs, built around generating clients and other tooling from one description. It can be produced from Rust macros or converted from an Anchor IDL, and Solana's explorer reads Codama IDLs registered as canonical program metadata. If a program publishes only a Codama IDL, its node tree carries the same essentials: instructions, arguments, accounts and type definitions. Older Anchor IDLs, before the 0.30 format, name types differently and carry no discriminators.

When no IDL is published#

Some heavily used programs have none, either because they are not built with Anchor or because the team never published one. Your options, in order of reliability: the program's own source code, if it is public; an official SDK, which must encode the same layout; and, last, inference from many real instructions checked against what the program logs and what balances change. Inference is a guess until a source confirms it, and a page in your codebase should say which of the three it came from.

Why a shred decoder lives or dies by its IDLs#

Shreds hand you instructions with no names, no parsed values and no logs to cross-check against at that moment. The IDL is the only thing standing between a byte string and a decoded swap, so a stale IDL fails silently: a renamed instruction stops matching, a new enum variant decodes as a different one, and a new argument shifts every field after it. Pin each IDL by commit or version, record where it came from, and re-check it against logged instruction names whenever you can. When the IDL changes and watching for program upgrades go deeper.

Questions about IDLs#

How do I fetch the on-chain Anchor IDL?#

Derive the address with create_with_seed from the program's signer address, the seed anchor:idl and the program ID, read the account, skip its 8-byte discriminator, 32-byte authority and 4-byte length, and inflate the rest with zlib. Anchor's command-line tool does the same with anchor idl fetch.

Does every Anchor program publish an IDL?#

No. Publishing is optional, on chain and off. Absence is common enough that your decoder needs a plan for it.

Can I trust a third-party IDL?#

As a starting point. Verify it against real instructions and the program's logs before you rely on it, and prefer the canonical one when both exist.

What an IDL cannot tell you#

An IDL describes shapes, not behaviour. It will not tell you what a field means economically, how amounts are scaled, which accounts move tokens, or what the program does on failure. It also cannot vouch for itself: nothing in the JSON proves it matches the deployed program. Common Borsh mistakes shows what goes wrong when it does not.

From IDL to working decoder#

The IDL-based decoder turns any of these IDLs into named instructions, the Jupiter recipe uses the on-chain IDL from the table above, and the Raydium AMM v4 recipe shows a program without one. Choosing parsed APIs instead of your own decoder avoids IDL upkeep at a cost, and a first decode from live shreds is the quickest way to try both.

Sources#

Raw shreds on your own server

Ultra Low Latency Shreds is $200 and Standard Shreds is $100. You pay in crypto, tell us which IPv4 address and UDP port should receive the stream, and we wire it up by hand.