#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

#51 in #cpi

Download history 13/week @ 2024-01-01 39/week @ 2024-01-08 37/week @ 2024-01-15 30/week @ 2024-01-22 16/week @ 2024-01-29 63/week @ 2024-02-05 41/week @ 2024-02-12 53/week @ 2024-02-19 64/week @ 2024-02-26 59/week @ 2024-03-04 63/week @ 2024-03-11 67/week @ 2024-03-18 79/week @ 2024-03-25 128/week @ 2024-04-01 43/week @ 2024-04-08 87/week @ 2024-04-15

342 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

~2.4–3.5MB
~70K SLoC