shank-parse
A proc-macro crate that generates type-safe Rust client code at compile time from Shank / Anchor IDL JSON files for Solana programs.
Features
- Zero boilerplate — point the macro at an IDL file and get fully-typed instruction builders, account deserializers, event decoders, and a program-ID constant.
- Compile-time code generation — the IDL is read and transformed during
cargo build; no runtime overhead. - Supports Shank & Anchor IDL format — works with any IDL that follows the common Shank/Anchor JSON schema.
- Submodule layout — generated code is organized into
instructions,accounts,events, andtypessubmodules.
Installation
Add both crates to your Cargo.toml:
[]
= "0.1"
= "3"
Usage
Place your IDL JSON file anywhere inside your crate (e.g. idl/my_program.json) and invoke the macro once:
shank_parse!;
The path is resolved relative to your crate's root (CARGO_MANIFEST_DIR).
Example — Counter program
Given idl/counter.json (a Shank IDL with an InitCounter and IncreaseCounter instruction):
shank_parse!;
use Counter;
use init_counter;
use ID;
Generated submodules
| Submodule | Contents |
|---|---|
<program>::instructions |
Instruction builder functions and argument structs |
<program>::accounts |
Account structs with from_account_data deserializers |
<program>::events |
Event structs with discriminant-based decoding |
<program>::types |
Shared domain enums used across instructions |
<program>::ID |
Pubkey constant from metadata.address in the IDL |
IDL format
The macro expects a JSON file following the Shank/Anchor IDL schema:
Workspace layout
shank-parse/
├── lib/ # shank-parse — the public-facing crate
└── macro/ # shank-parse-macro — the proc-macro implementation
License
MIT — see LICENSE.