#anchor #generate #idl #solana #json #cpi #declare-id

macro clockwork-anchor-generate-cpi-crate

Generates an Anchor CPI crate from a JSON IDL

2 releases

0.3.2 Apr 10, 2023
0.3.1 Mar 31, 2023

#52 in #cpi

Download history 77/week @ 2024-04-11 86/week @ 2024-04-18 86/week @ 2024-04-25 71/week @ 2024-05-02 74/week @ 2024-05-09 83/week @ 2024-05-16 80/week @ 2024-05-23 73/week @ 2024-05-30 49/week @ 2024-06-06 58/week @ 2024-06-13 79/week @ 2024-06-20 45/week @ 2024-06-27 16/week @ 2024-07-04 56/week @ 2024-07-11 71/week @ 2024-07-18 55/week @ 2024-07-25

198 downloads per month
Used in 17 crates (via clockwork-anchor-gen)

Apache-2.0

27KB
629 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
~91K SLoC