#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 251/week @ 2024-03-14 283/week @ 2024-03-21 344/week @ 2024-03-28 211/week @ 2024-04-04 265/week @ 2024-04-11 208/week @ 2024-04-18 196/week @ 2024-04-25 212/week @ 2024-05-02 568/week @ 2024-05-09 736/week @ 2024-05-16 536/week @ 2024-05-23 621/week @ 2024-05-30 632/week @ 2024-06-06 386/week @ 2024-06-13 464/week @ 2024-06-20 544/week @ 2024-06-27

2,091 downloads per month
Used in 18 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
~87K SLoC