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

macro anchor-generate-cpi-crate

Generates an Anchor CPI crate from a JSON IDL

2 releases

0.3.1 Sep 27, 2022
0.3.0 Jul 26, 2022

#4 in #anchor-gen

Download history 273/week @ 2024-07-24 250/week @ 2024-07-31 423/week @ 2024-08-07 463/week @ 2024-08-14 475/week @ 2024-08-21 497/week @ 2024-08-28 580/week @ 2024-09-04 554/week @ 2024-09-11 435/week @ 2024-09-18 477/week @ 2024-09-25 440/week @ 2024-10-02 544/week @ 2024-10-09 981/week @ 2024-10-16 1540/week @ 2024-10-23 2092/week @ 2024-10-30 1307/week @ 2024-11-06

6,044 downloads per month
Used in 24 crates (via anchor-gen)

Apache-2.0

25KB
558 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
~90K SLoC