Skip to main content
Version: v3.0.0-nightly.20251231

Aztec Macros

Aztec.nr provides macros (attributes) that transform your code during compilation to handle the complexities of private execution, proof generation, and state management.

Quick reference

Contract

AttributePurpose
#[aztec]Marks a module as an Aztec contract

Functions

AttributePurpose
#[external("private")]Client-side private execution with proofs
#[external("public")]Sequencer-side public execution
#[external("utility")]Unconstrained queries, not included in transactions
#[internal("private")]Private helper, inlined at call sites
#[internal("public")]Public helper, inlined at call sites
#[view]Prevents state modification
#[initializer]Contract constructor
#[noinitcheck]Callable before contract initialization
#[nophasecheck]Skips transaction phase validation
#[only_self]Only callable by the same contract
#[authorize_once]Requires authwit authorization with replay protection

Functions can have multiple attributes (e.g., #[external("public")] with #[view] and #[only_self]).

Structs

AttributePurpose
#[note]Defines a private note type
#[custom_note]Note with custom hash/nullifier logic
#[storage]Defines contract storage layout
#[storage_no_init]Storage with manual slot allocation

For detailed explanations and examples, see the Attributes and Macros reference.

Further reading