Skip to main content
The Interface Description Language (IDL) is a JSON specification that describes an Anchor program’s public interface. The IDL enables automatic client generation and provides a standardized way to interact with Solana programs.

What is an IDL?

The IDL contains:
  • Program metadata (name, version, address)
  • Instruction definitions with parameters
  • Account structures and types
  • Custom type definitions
  • Error codes and messages
  • Events emitted by the program

Generating IDLs

Anchor automatically generates IDLs during the build process:
The IDL is output to:
  • JSON format: target/idl/<program_name>.json
  • TypeScript format: target/types/<program_name>.ts

IDL build feature

To generate IDLs, programs must have the idl-build feature enabled in Cargo.toml:
This is automatically added to new Anchor projects.

IDL structure

Basic example

Instructions

Each instruction includes:

Account types

Custom types

Error codes

Using IDLs

TypeScript client

Anchor generates TypeScript types from the IDL:

Rust client

Use declare_program! to generate Rust types:

IDL CLI commands

Build IDL

Generate IDL without building the program:

Fetch IDL

Download IDL from a deployed program:

Initialize IDL account

Upload IDL to the blockchain:

Upgrade IDL

Update an existing on-chain IDL:

Discriminators

Discriminators are 8-byte identifiers that uniquely identify instructions and accounts:
Custom discriminators can be specified:

IDL parsing

Read and parse IDL files programmatically:

Best practices

Enable idl-build feature - Ensure all programs have idl-build in their feature flags.
Version your IDLs - Store IDL snapshots when deploying to track changes over time.
Upload IDLs on-chain - Use anchor deploy (which uploads IDL by default) or anchor idl init for client discoverability.

Next steps

TypeScript client

Use IDLs with the TypeScript client

IDL CLI reference

Complete IDL command reference