#anchor #cpi #generate #idl #solana #json #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

#68 in #cpi

Download history 19/week @ 2024-11-13 46/week @ 2024-11-20 64/week @ 2024-11-27 67/week @ 2024-12-04 120/week @ 2024-12-11 56/week @ 2024-12-18 2/week @ 2024-12-25 47/week @ 2025-01-01 53/week @ 2025-01-08 101/week @ 2025-01-15 72/week @ 2025-01-22 58/week @ 2025-01-29 165/week @ 2025-02-05 93/week @ 2025-02-12 57/week @ 2025-02-19 81/week @ 2025-02-26

407 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
~98K SLoC