#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 447/week @ 2024-05-22 688/week @ 2024-05-29 635/week @ 2024-06-05 428/week @ 2024-06-12 419/week @ 2024-06-19 617/week @ 2024-06-26 163/week @ 2024-07-03 265/week @ 2024-07-10 278/week @ 2024-07-17 277/week @ 2024-07-24 248/week @ 2024-07-31 419/week @ 2024-08-07 460/week @ 2024-08-14 475/week @ 2024-08-21 499/week @ 2024-08-28 467/week @ 2024-09-04

2,007 downloads per month
Used in 22 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

~4.5MB
~92K SLoC