Every Quasar program starts with aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/blueshift-gg/quasar/llms.txt
Use this file to discover all available pages before exploring further.
#[program] module. This single attribute generates the instruction dispatch table, the event authority PDA required for spoofing-resistant events, and all of the entrypoint wiring needed for the Solana runtime — all without a heap allocator or dynamic dispatch.
declare_id! and Program Identity
Before the #[program] module, call declare_id! to register your program’s on-chain address. This address becomes crate::ID and is used by the Owner trait impl generated for every #[account] type in the crate:
declare_program!:
The #[program] Module
Annotate a mod block with #[program] and define one function per instruction inside it. Each function must be annotated with #[instruction(discriminator = N)]:
What #[program] Generates
dispatch! router
The macro emits a
dispatch! call that matches the first discriminator byte(s) of incoming instruction data against each registered handler. Account parsing runs inside the matching arm using a stack-allocated MaybeUninit<[AccountView; N]> buffer sized to the exact account count.no_alloc! + panic_handler!
Two macros set up the runtime environment for the generated For programs that legitimately need heap access (e.g. for string formatting in tests), use
entrypoint:no_alloc!()registers a global allocator that callsabort_program()on any allocation attempt, enforcing the zero-allocation guarantee at runtime.panic_handler!()installs a#[panic_handler]that also callsabort_program().
heap_alloc!() in place of no_alloc!() to install a bump allocator instead.Event authority PDA
The macro generates a constant
EventAuthority type with a BUMP byte — the canonical __event_authority PDA derived from b"__event_authority" and the program ID. This PDA signs emit_cpi! self-CPI invocations to make events unforgeable.The __handle_event dispatch arm validates that the first account is a signer matching this PDA, then calls sol_log_data with the event payload.Project Layout from quasar init
Running quasar init my-program scaffolds the following structure:
src/lib.rs from a freshly scaffolded project:
src/state.rs starter:
src/errors.rs starter:
Adding New Instructions with quasar add
The CLI’s quasar add instruction <name> command scaffolds a new instruction file, updates src/instructions/mod.rs, and inserts a new handler stub into the #[program] block:
src/instructions/transfer.rs:
src/lib.rs:
#![no_std] Requirement
All Quasar programs must declare #![no_std] at the top of lib.rs. The framework itself is a no_std crate; alloc is available when no_alloc!() is replaced with heap_alloc!(), but the standard library is never available on-chain.
