declare_program!() { /* proc-macro */ }Expand description
Generates a module from an Anchor IDL JSON file.
Looks for idls/{name}.json by walking up from CARGO_MANIFEST_DIR.
§Generated items
ID— programPubkeyaccounts— account structs implementingAccountDeserializeevents— event structs withfrom_logs/from_cpi_logsinstructions— builder functions returningInstructiontypes— shared structs, enums, and type aliasesconstants— program constantsutils—Event/Accountwrapper enums
§Example
ⓘ
anchor_parser::declare_program!(my_program);
// Now use my_program::accounts, my_program::events, etc.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;