declare_program!() { /* proc-macro */ }Expand description
Generate a complete program module from an Anchor IDL JSON file.
Searches for idls/{name}.json by walking up from CARGO_MANIFEST_DIR.
§Generated items
ID— the program’sPubkeytypes— shared structs, enums, and type aliasesaccounts— account structs with discriminator and deserializationevents— event structs withfrom_logs/from_cpi_logsparsersinstructions— builder functions →Result<Instruction, io::Error>constants— program constantsutils—Event/Accountwrapper enums
§Example
ⓘ
anchor_parser::declare_program!(my_program);
// Use generated types:
use my_program::accounts::MyAccount;
use my_program::events::MyEvent;
use my_program::instructions;