Sysvars are special Solana accounts that the runtime continuously updates with cluster-level information such as the current slot, epoch, rent rates, and timestamps.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.
Sysvar<T> is Quasar’s zero-copy wrapper for these accounts. During account parsing it validates that the account address matches the canonical sysvar address (T::ID), then provides a Deref<Target = T> that casts directly into the sysvar account data — no heap allocation, no deserialization.
How Sysvar<T> Works
Sysvar<T> is #[repr(transparent)] over AccountView and implements AccountLoad to check the address:
Deref implementation calls T::from_bytes_unchecked on the raw account data, which is a pointer cast:
#[repr(C)] with alignment 1, making the pointer cast sound on all targets.
Sysvar<Rent>
TheRent sysvar provides the network’s current rent parameters. These are used when creating accounts to determine the lamport balance needed for rent exemption.
Rent Struct Fields
Rent Methods
Using Rent in an Accounts Struct
#[account(init, ...)] is present, Quasar uses the Rent sysvar internally to compute the required lamport balance. You still need to declare rent: Sysvar<Rent> in your struct so the account slot is available to the parser.
Computing Minimum Balance Manually
If you need to compute rent exemption yourself (for example, when reallocating accounts):Sysvar<Clock>
TheClock sysvar provides the current cluster time. Quasar’s Clock struct captures slot, epoch, timestamps, and leader schedule epoch.
Clock Struct Fields
PodU64 and PodI64 are unaligned pod wrappers. Call .get() to extract the underlying integer value.Accessing Clock Fields
Declaring Both Sysvars
Many instructions need bothRent (for account init) and Clock (for time-based logic):
When Rent Is Required
Account initialization
Any instruction that uses
#[account(init, ...)] must include pub rent: Sysvar<Rent> in the accounts struct. Quasar reads it to calculate the rent-exempt lamport balance before calling the system program CPI.Manual reallocation
When calling
account.realloc(new_space, payer, Some(&*ctx.accounts.rent)), pass the Rent sysvar explicitly. If you pass None, Quasar will fetch it via a syscall instead.Migration
Migration<From, To>::migrate(&payer, data) always fetches rent via syscall internally. Declaring rent: Sysvar<Rent> in a migration instruction is not required for the migrate call itself; it is only needed if your handler also performs additional account operations that require explicit rent access.