#solana #generate #cross-program #gen

anchor-gen

Generates an Anchor CPI crate from a JSON IDL

6 releases

0.3.1 Sep 27, 2022
0.3.0 Jul 26, 2022
0.2.0 Jul 24, 2022
0.1.2 Jun 6, 2022

#3 in #gen

Download history 2480/week @ 2024-12-01 3283/week @ 2024-12-08 1793/week @ 2024-12-15 1773/week @ 2024-12-22 1498/week @ 2024-12-29 2616/week @ 2025-01-05 2650/week @ 2025-01-12 2066/week @ 2025-01-19 3106/week @ 2025-01-26 3269/week @ 2025-02-02 2949/week @ 2025-02-09 3302/week @ 2025-02-16 2664/week @ 2025-02-23 2259/week @ 2025-03-02 2302/week @ 2025-03-09 2704/week @ 2025-03-16

10,065 downloads per month
Used in 30 crates (28 directly)

Apache-2.0

4KB

anchor-gen

Generates a crate for cross-program invocations to an Anchor program from a JSON IDL.

Usage

In a new crate, write:

anchor_gen::generate_cpi_crate!("../../examples/govern-cpi/idl.json");

declare_id!("GjphYQcbP1m3FuDyCTUJf2mUMxKPE3j6feWU1rxvC7Ps");

This will generate a fully functional Rust CPI client for your IDL.

More examples can be found in the examples/ directory.

License: Apache-2.0


lib.rs:

Generates a crate for cross-program invocations to an Anchor program from a JSON IDL.

Usage

In a new crate, write:

anchor_gen::generate_cpi_crate!("../../examples/govern-cpi/idl.json");

declare_id!("GjphYQcbP1m3FuDyCTUJf2mUMxKPE3j6feWU1rxvC7Ps");

This will generate a fully functional Rust CPI client for your IDL.

More examples can be found in the examples/ directory.

Dependencies

~4.5MB
~100K SLoC