solana/idl-codegen
IDL & Client Code Generation
solanatechnical-doc🏛️ Officialconfidence highhealth 100%
v1.0.0·by solana-foundation·Updated 4/11/2026
Goal
Never hand-maintain multiple program clients by manually re-implementing serializers. Prefer an IDL-driven, code-generated workflow.
Codama (preferred)
- Use Codama as the "single program description format" to generate:
- TypeScript clients (including Kit-friendly output)
- Rust clients (when available/needed)
- documentation artifacts
Anchor → Codama
If the program is Anchor:
- Produce Anchor IDL from the build
- Convert Anchor IDL to Codama nodes (nodes-from-anchor)
- Render a Kit-native TypeScript client (codama renderers)
Native Rust → Shank → Codama
If the program is native:
- Use Shank macros to extract a Shank IDL from annotated Rust
- Convert Shank IDL to Codama
- Generate clients via Codama renderers
Repository structure recommendation
programs/<name>/(program source)idl/<name>.json(Anchor/Shank IDL)codama/<name>.json(Codama IDL)clients/ts/<name>/(generated TS client)clients/rust/<name>/(generated Rust client)
Generation guardrails
- Codegen outputs should be checked into git if:
- you need deterministic builds
- you want users to consume the client without running codegen
- Otherwise, keep codegen in CI and publish artifacts.
"Do not do this"
- Do not write IDLs by hand unless you have no alternative.
- Do not hand-write Borsh layouts for programs you own; use the IDL/codegen pipeline.