On Solana, IDLs are JSON files that describe the interface of a program. They allow explorers and users to decode program instructions, account data, and program errors and offer the possibility to generate clients in different program languages.
Why IDLs Matter
- Standardization → A shared format for program interfaces.
- Developer Experience → Generate client SDKs automatically.
- Composability → Other developers can interact with your program without reading its source code.
- Readability → Everyone can read program instructions and account data in explorers without reading the program’s source code.
What you can do with IDLs
Decoding Instruction and Account Data
All Explorers use program IDLs to decode instructions and account data. Here you can see a Anchor 0.30.1 and a Legacy IDL example in the Solana Explorer UI. In this transaction you can see the decoded instruction for a 2048 game, includingpushInDirection
and its direction.
You can decode instructions and account data in your typescript client by using
the
Solana JS helpers.
Parsing account changes
You can easily subscribe to account changes in your program by using the generated TypeScript types.Decode Transactions
You can also decode transactions in your client by using the Solana JS helpers. This will give you a typed object of the whole transaction.Build your own client
Using an IDL you can create your own client in many languages. You just find a program you want to interact with, download the IDL and then you can generate a client in your preferred language. Here is an example of how to generate a client in TypeScript.IDLs in Anchor
If you’re using the Anchor framework:- The IDL is auto-generated when you build your program.
- It lives in
target/idl/<program>.json. - TypeScript types are generated in
target/types/<program>.ts. - The program address is stored in the IDL (
idl.address).
Anatomy of an IDL
Here’s a minimal example (Anchor v0.30+ spec):- address: the onchain program ID.
- metadata:
{ name, version, spec, ... }about the program/interface. - instructions: callable methods with
accounts,args, and adiscriminator. - accounts: account types exposed by the program (with discriminators).
- types: struct/enum/type aliases referenced by instructions/accounts.
- events / errors / constants: optional definitions for events, error codes, constants.
Note: Anchor v0.30 introduced a new IDL spec. Legacy IDLs (pre-0.30) used fields likename,versionat top level, andisMut/isSignerin accounts. You can convert legacy IDLs usinganchor idl convertor rebuild with Anchor v0.30+. If you need to convert a legacy IDL to the new spec on the fly you can also use this conversion code. This is useful for example if you maintain a solana explorer and want to stay backwards compatible.
TypeScript Client
Anchor will also automatically generate a TypeScript client for you. You can find the generated client in thetarget/types folder.
Then in your client (TypeScript, v0.30+) you can call program instructions and
fetch accounts as easy as this:
C# Client
To generate a C# client you can use the following command:Python Client
For Python, codama-py generates a client from the IDL. AnchorPy also generates Python clients for Anchor programs, but it is no longer updated (last release 0.21.0, March 2025) and requires solana-py 0.36. More client generators will be available using Codama renderers in the future.IDLs Without Anchor
Not all programs are built with Anchor.For native Solana programs:
- A tool called Codama is currently
in development to generate IDLs from Rust via macros or by converting Anchor
IDLs. Here is an in progress example of
Codama Macros
to generate a Codama IDL. Codama converts Anchor/Shank IDLs into a Codama IDL.
To get an Anchor IDL, generate it with Anchor (or use
anchor idl convertfor legacy projects). - Until the codama macros are completely ready you can also use Metaplex Shank to generate a Shank IDL, then convert it to a Codama IDL.
- You can also write the IDL by hand (Anchor or Codama formats) but this is not very reliable. AI tools like Cursor can help you to write the IDL but you should always verify the IDL with the program source code and the better way is to use Anchor, Codama, or Metaplex Shank.
Storing IDLs Onchain
There are two ways to upload IDLs onchain: the Program Metadata Program (PMP), which is what Anchor 1.x uses, and the legacy Anchor IDL account. In the PMP all the program IDLs and security.txt info like name, contact, and icon are stored in PDAs of the program metadata program. The legacy mechanism adds extra instructions to your program, which increases program size and is why the PMP was created.Anchor IDL commands (Anchor 1.x)
In Anchor 1.x,anchor idl init, and anchor idl upgrade write to Program
Metadata Program accounts, so explorers, wallets, and SDKs can fetch the IDL
directly from Solana.
First time (initialize the IDL):
Anchor skips IDL uploads on a local validator. With
localnet or a
localhost/127.0.0.1 URL as the cluster, anchor idl init and
anchor idl upgrade print Skipping IDL initialization on localnet (or
Skipping IDL upgrade on localnet), upload nothing, and exit successfully, so
a later anchor idl fetch finds no account. Use devnet, as in the commands
above, to try IDL uploads.anchor idl also provides build, fetch-historical, convert, type,
close, create-buffer, set-buffer-authority, and write-buffer. Run
anchor idl --help for details.
Legacy Anchor IDL account
Before Anchor 1.0, Anchor saved IDLs onchain in a PDA of your program. The authority commands for that account now live under the deprecatedanchor legacy-idl subcommand:
anchor idl authority, anchor idl set-authority, and
anchor idl erase-authority. For the legacy account, upload was permissionless
by default, so upload your IDL as soon as possible and then set an authority.
You can read more about Anchor IDLs in the
Anchor docs.
Program Metadata Program (PMP)
The program metadata program is a program that allows you to store the program IDLs and security.txt info like name, contact, and icon onchain. This will probably be the standard way to store IDLs onchain in the future.Best Practices
The best practise for program deploys is to use a Multisig like Squads and to make this process as easy as possible you use the Solana GitHub Actions workflows. Like this the program will automatically be upgraded, IDL uploaded, the build verified, and then there will be a transaction proposed for your multisig to sign and deploy the program.- Keep IDLs updated → Always update the IDL when you make changes to your program.
- Upload IDLs onchain → for transparency and tooling support.
- Document custom errors → improves UX for clients.
- Verify builds → ensure the IDL matches the deployed program.
Versioning IDLs
Currently with Anchor you can only have one version of the IDL onchain at a time. This means that if you want to make changes to your program you need to upload a new version of the IDL, preferably at the same time as you upgrade the program. This can lead to problems if the clients are not updated yet and is one reason why the program metadata program was written. With PMP, you will be able to have different seeds for your program and do versioning like that. The design for that is not completely final yet and open for discussion.Further Reading
- Anchor Docs on IDLs → auto-generates IDLs and clients. (TypeScript, C#, Python)
- Codama → IDL tooling + client generators (Rust, JS/TS, Umi/Kit, etc.).
- Program Metadata Program → store IDLs and security.txt information onchain.
That’s the basics of IDLs on Solana. They’re the bridge between onchain programs and offchain clients, enabling the rich ecosystem of tools and SDKs you see today.