#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 352/week @ 2024-02-26 234/week @ 2024-03-04 384/week @ 2024-03-11 258/week @ 2024-03-18 269/week @ 2024-03-25 344/week @ 2024-04-01 236/week @ 2024-04-08 208/week @ 2024-04-15 225/week @ 2024-04-22 170/week @ 2024-04-29 289/week @ 2024-05-06 951/week @ 2024-05-13 406/week @ 2024-05-20 713/week @ 2024-05-27 608/week @ 2024-06-03 441/week @ 2024-06-10

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