Quasar ships with a full-featured CLI that handles everything from project scaffolding to deployment. This guide walks you through installing the CLI, generating a new project, writing a simple counter program, running tests, and deploying — all without leaving your terminal. By the end you will have a working on-chain Solana program built with Quasar’s zero-copy account model.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.
Prerequisites
Before you begin, make sure the following tools are installed:- Rust — install via rustup.rs
- Solana CLI — install via the Solana docs; required for
quasar deployand local validator testing - Cargo — bundled with Rust; used to install and build the CLI
Steps
The CLI saves your choices (toolchain, test framework, template) the first time you run
quasar init. Subsequent projects skip the prompts when you pass --yes.solana (uses cargo build-sbf) or upstream (uses cargo +nightly build-bpf)none, rust, or typescriptquasar-svm or molluskkit or web3.jsminimal (instruction file only) or full (state, errors, and instruction files)quasar init my-program \
--yes \
--template minimal \
--test-language rust \
--rust-framework quasar-svm \
--toolchain solana
--templateminimal, full--test-languagenone, rust, typescript--rust-frameworkquasar-svm, mollusk--test-language rust)--ts-sdkkit, web3.js--test-language typescript)--toolchainsolana, upstream--no-gitgit init and the initial commit--yes / -yNAME as positional argumentOpen
src/lib.rs (or the generated instruction file) and replace the placeholder with a counter program. The example below is the canonical Quasar “Hello, World”:use quasar_lang::prelude::*;
declare_id!("22222222222222222222222222222222222222222222");
// Define on-chain account state.
// discriminator = 1 is a developer-chosen byte prefix.
#[account(discriminator = 1)]
pub struct Counter {
pub authority: Address,
pub count: u64,
}
// Declare the accounts required by the `increment` instruction.
#[derive(Accounts)]
pub struct Increment<'info> {
#[account(has_one = authority)]
pub counter: &'info mut Account<Counter>,
pub authority: &'info Signer,
}
// Group all instruction handlers under #[program].
#[program]
mod counter_program {
use super::*;
// discriminator = 0 is the byte prefix for this instruction.
#[instruction(discriminator = 0)]
pub fn increment(ctx: Ctx<Increment>) -> Result<(), ProgramError> {
ctx.accounts.counter.count += 1;
Ok(())
}
}
declare_id! — sets the program address that #[program] will check at runtime. Run quasar keys sync to keep this in sync with your deploy keypair.#[account(discriminator = 1)] — generates the #[repr(C)] zero-copy companion for Counter and tags it with discriminator byte 1. The framework rejects any account whose first byte is not 1.#[derive(Accounts)] on Increment — generates parse_accounts code that walks the SVM input buffer, validates signer and writable flags, checks the has_one = authority constraint, and pointer-casts the counter data without copying.#[program] — wraps the module in the program entrypoint, generates the dispatch! match on the instruction discriminator, and wires each #[instruction] function to its byte prefix.#[instruction(discriminator = 0)] — registers increment as handler [0]. The runtime routes any instruction whose first byte is 0 to this function.Ctx<Increment> — the parsed instruction context; ctx.accounts gives you the validated, zero-copy account struct ready to use.The
has_one = authority constraint verifies that counter.authority == authority.key() at validation time — before your instruction body runs.# Emit debug symbols (required for quasar profile and quasar dump --source)
quasar build --debug
# Rebuild automatically whenever src/ changes
quasar build --watch
# Enable optional Cargo features
quasar build --features my-feature
# Only run tests whose name contains "increment"
quasar test --filter increment
# Show stdout from the test binary
quasar test --show-output
# Re-run tests on every src/ change
quasar test --watch
# Skip rebuilding (use existing binary)
quasar test --no-build
quasar test builds the program before running tests by default. Pass --no-build to skip the build step when you know the binary is already up to date.# Deploy to devnet
quasar deploy --url https://api.devnet.solana.com
# Use a specific payer keypair
quasar deploy --keypair ~/.config/solana/devnet-payer.json
# Deploy without rebuilding first
quasar deploy --skip-build
Other Useful CLI Commands
Once your project is running, the CLI offers several additional tools:What’s Next
Core Concepts
Learn how Quasar’s zero-copy model works under the hood: the SVM input buffer,
repr(C) layouts, discriminators, and the bump cache.Accounts Reference
Full documentation for
Account<T>, Signer, UncheckedAccount, Program<T>, InterfaceAccount<T>, and every other account type.