Skip to main content

declare_program

Macro declare_program 

Source
declare_program!() { /* proc-macro */ }
Expand description

Declare a program module from an Anchor IDL JSON file.

Looks for idls/{name}.json by walking up from CARGO_MANIFEST_DIR.

ยงExample

โ“˜
anchor_parser::declare_program!(my_program);

This generates a module my_program containing:

  • ID constant (Pubkey)
  • types module (struct/enum/alias definitions)
  • accounts module (account types with discriminators + fetch)
  • events module (event types with from_log)
  • instructions module (instruction builders โ†’ Instruction)
  • constants module