ChewingGlass/idl-spec

Defines the standard IDL format for Solana programs to enable tooling, explorers, and SDKs to interact with on-chain programs in a consistent way. Owned by the community coordinated by Solana Foundation.

★ 0Forks 0GitHub ↗Compare

README

Solana IDL Specification

A unified reference for Solana program Interface Description Language (IDL) formats. IDLs describe the public interface of on-chain programs -- their instructions, accounts, types, events, errors, and constants -- enabling tooling to generate clients, documentation, and transaction builders automatically.

This first version of the specification is based on the anchor-lang-idl-spec and will serve as a framework-agnostic standard for all Solana IDLs.

Specification

Version Status Document JSON Schema
0.1.0 Current specs/v0.1.0.md schema/v0.1.0.json

Ecosystem Tools

Frameworks

Frameworks that generate IDLs conforming to this spec:

  • Anchor -- Solana program framework maintained by Ottersec. Generates IDLs at build time via anchor build.

  • Quasar -- Solana program framework maintained by Blueshift. Generates IDLs at build time via quasar build.

  • Native or Pinocchio programs can also generate Codama IDLs via Codama macros. This Solana IDL spec can be converted to Codama IDLs if needed.

Client Generation

Anchor

Anchor automatically generates Web3js clients for your program via anchor build.

Quasar

Quasar automatically generates Js clients and Rust clients for your program via quasar build.

Codama

The Solana IDL can be converted easily into a Codama IDL and then be used for client generation.

Codama -- Generate typed clients from Solana IDL. Supports multiple target languages (TypeScript, Rust, Go, Python, etc.).

pnpm install codama
codama init
codama run --all

C#

You can generate C# clients for your program via the Magic block sdk.

dotnet anchorgen -i idl/file.json -o src/ProgramCode.cs

Upload & Manage On-Chain Metadata

Program Metadata -- Attach IDLs, security.txt, and other metadata to any Solana program via on-chain PDA accounts. Also offers multisig support.

# Upload an IDL to your program
npx @solana-program/program-metadata@latest write idl <program-id> ./idl.json

# Fetch an IDL from a deployed program
npx @solana-program/program-metadata@latest fetch idl <program-id> --output ./idl.json

Using the legacy IDL upload via the injected anchor code into anchor programs is deprecated for security reasons and you should move to use the new Program Metadata program.

Historical IDL Indexing

Historical IDL -- Reconstruct the full version history of a Solana program's IDL from on-chain transactions. Supports both legacy Anchor IDL and Program Metadata formats.

npx tsx src/cli.ts <program-address> --rpc <rpc-url> --type both --dump-idls ./idls

Repository Structure

idl-spec/
├── README.md                   # This file
├── CONTRIBUTING.md             # Contribution guidelines and RFC process
├── LICENSE                     # MIT license
├── schema/
│   └── v0.1.0.json             # JSON Schema for IDL validation
├── specs/
│   └── v0.1.0.md               # IDL spec v0.1.0
└── examples/
    └── counter.json            # Example IDL

Contributing

Contributions are welcome. See CONTRIBUTING.md for full details.

  • Spec changes go through the RFC process -- open an issue using the RFC template, allow at least 2 weeks for discussion, then submit a PR once accepted. For breaking changes lets do 4 weeks.
  • Tooling additions, examples, and editorial fixes can be submitted as a standard pull request.

License

This project is licensed under the MIT License.

Contributors

Woody4618clubby789

Issues