The Anchor IDL
The Anchor IDL is a JSON description of your program's instructions, accounts, types, events, and errors. anchor build regenerates it from Rust macros.
Search across all documentation pages
The Anchor IDL is a JSON description of your program's instructions, accounts, types, events, and errors. anchor build regenerates it from Rust macros.
anchor build
ls target/idl/my_program.json{
"address": "Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS",
"instructions": [ { "name": "initialize", "accounts": [], "args": [] } ],
"errors": [],
"events": []
}When to reach for this: You integrate clients, CPI consumers, or publish on-chain metadata.
// Rust macros drive IDL content
#[program]
pub mod my_program { /* ... */ }
#[account]
pub struct Config { pub admin: Pubkey }
#[event]
pub struct ConfigUpdated { pub admin: Pubkey }
#[error_code]
pub enum MyError { #[msg("Unauthorized")] Unauthorized }After build, IDL includes all public instructions, account types, events, and errors.
What this demonstrates:
declare_program! CPI generationTag IDL JSON with program release. Breaking account layout changes require client bumps.
| Alternative | Use When | Don't Use When |
|---|---|---|
| On-chain IDL account | Discoverable on-chain | Repo-only IDL |
| Codama IDL transform | Kit-native output | Raw Anchor IDL only |
0.32.1 across advanced topics.
Large fixed layouts when Borsh CU too high.
Not easily; plan forward growth.
No; document separately.
Callee IDL JSON at compile time.
Yes with correct account metas.
Avoid different IDL per feature on mainnet.
LiteSVM, Surfpool, devnet simulation.
No; last resort.
See Related links for idl.
Stack versions: This page was written for Agave 4.1.1, Solana CLI 3.0.10, Anchor 0.32.1, anchor-lang 0.32.1, Rust 1.91.1, @solana/kit 7.0.0, Surfpool 0.12.0, and LiteSVM 0.6.x.
Reviewed by Chris St. John·Last updated Jul 19, 2026