On-Chain IDLs
Anchor can store IDL on-chain in a program-owned account so explorers and clients fetch canonical interfaces by program ID.
Search across all documentation pages
Anchor can store IDL on-chain in a program-owned account so explorers and clients fetch canonical interfaces by program ID.
anchor idl init -f target/idl/my_program.json <PROGRAM_ID>
anchor idl fetch <PROGRAM_ID> -o idl/my_program.jsonWhen to reach for this: You want discoverable interfaces without relying solely on GitHub.
# After deploy and build
anchor idl init -f target/idl/my_program.json Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS --provider.cluster devnet
# Consumers fetch
anchor idl fetch Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS -o fetched.jsonWhat this demonstrates:
On-chain IDL is convenient, not a substitute for reproducible builds. Pair with verified program hashes.
Large IDLs may need chunking strategies; monitor account size and rent.
| Alternative | Use When | Don't Use When |
|---|---|---|
| GitHub releases only | Full CI review | Wallet/explorer discoverability |
| npm IDL package | Versioned installs | On-chain discovery |
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 on-chain 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 16, 2026