Documentation 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<T> is Quasar’s typed wrapper for program accounts. During account parsing it validates two things: the executable flag must be set in the SVM account header, and the account’s address must exactly equal T::ID. If either check fails, parsing returns ProgramError::IncorrectProgramId. The wrapper is then #[repr(transparent)] over AccountView, giving zero-cost access to the underlying program account.
What Program<T> Validates
TheProgram<T> AccountLoad implementation enforces both checks:
IS_EXECUTABLE = true causes the generated account-parsing code to assert view.executable() before calling check. The check body then compares the address against T::ID.
The Id Trait
T must implement Id, which simply provides a compile-time address constant:
impl Id can be used as the type parameter for Program<T>. For convenience, Quasar provides built-in program marker types.
Built-in Program Markers
SystemProgram
ID = 11111111111111111111111111111111Used for account creation, lamport transfers, and allocation. Program<SystemProgram> also has helper methods like create_account() and transfer().TokenProgram
ID = TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DASPL Token program. Program<TokenProgram> implements TokenCpi for typed token operations.Token2022Program
ID = TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEbToken Extensions (Token-2022) program. Program<Token2022Program> also implements TokenCpi.Usage in Accounts Structs
Declare program accounts without#[account(mut)] — programs are always read-only:
Getting the Program ID
Program<T> implements Id, so T::ID is always available at compile time. At runtime, you can also retrieve the program’s address through AsAccountView:
Calling CPIs via Program Methods
Program<SystemProgram> and Program<TokenProgram> expose strongly-typed CPI builder methods:
.invoke() call at the end dispatches the CPI. For PDA-signed CPIs use .invoke_signed(&seeds) instead.
Interface<T> for Multiple Programs
When an instruction must accept either SPL Token or Token-2022, useInterface<T> with a ProgramInterface marker type instead of Program<T>:
Interface<T> requires T: ProgramInterface, which provides a matches(address: &Address) -> bool method. Quasar calls this at parse time instead of a single address equality check:
InterfaceAccount<T> for Multi-Owner Accounts
For data accounts that may be owned by any program in an interface set (for example, a token account owned by eitherTokenProgram or Token2022Program), use InterfaceAccount<T>:
InterfaceAccount<T> validates the owner against T::owners() at parse time. It supports the same zero-copy Deref/DerefMut as Account<T>.
ProgramInterface for Custom Interfaces
ImplementProgramInterface on your own marker type to create custom multi-program interfaces:
emit_event via Program
Program<T> also provides an emit_event method for self-CPI event emission, used when the instruction includes an event authority account:
