Skip to main content

declare_id

Macro declare_id 

Source
macro_rules! declare_id {
    ($address:expr) => { ... };
}
Expand description

Convenience macro to declare a static program ID and helper functions.

Input: a single literal base58 string representation of a program’s ID.

This generates:

  • A const ID: Pubkey — the program ID, decoded at compile time.
  • A fn check_id(id: &Pubkey) -> bool — returns true if the given pubkey matches.
  • A const fn id() -> Pubkey — returns the program ID.

§Example

ⓘ
use arch_program::declare_id;

declare_id!("MyProgram111111111111111111111111111111111");

assert_eq!(id(), ID);
assert!(check_id(&id()));