#anchor #generate #solana #idl #json #cpi #anchor-gen

macro anchor-generate-cpi-interface

Generates an Anchor CPI crate from a JSON IDL

2 releases

0.3.1 Sep 27, 2022
0.3.0 Jul 26, 2022

#5 in #anchor-gen

Download history 231/week @ 2023-12-22 199/week @ 2023-12-29 372/week @ 2024-01-05 441/week @ 2024-01-12 206/week @ 2024-01-19 740/week @ 2024-01-26 184/week @ 2024-02-02 230/week @ 2024-02-09 328/week @ 2024-02-16 411/week @ 2024-02-23 245/week @ 2024-03-01 406/week @ 2024-03-08 256/week @ 2024-03-15 268/week @ 2024-03-22 344/week @ 2024-03-29 199/week @ 2024-04-05

1,117 downloads per month
Used in 17 crates (via anchor-gen)

Apache-2.0

25KB
562 lines

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

~4MB
~85K SLoC