Skip to main content

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.

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.

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 deploy and local validator testing
  • Cargo — bundled with Rust; used to install and build the CLI

Steps

1
Install the Quasar CLI
2
Install directly from the repository source:
3
cargo install --path cli
4
Verify the installation:
5
quasar --version
6
The CLI command summary is always available:
7
quasar --help
8
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.
9
Scaffold a New Project
10
Create a new Quasar project with the interactive scaffolder:
11
quasar init my-program
12
The CLI will prompt you to choose:
13
  • Toolchain: solana (uses cargo build-sbf) or upstream (uses cargo +nightly build-bpf)
  • Test language: none, rust, or typescript
  • Rust test framework (if Rust): quasar-svm or mollusk
  • TypeScript SDK (if TypeScript): kit or web3.js
  • Template: minimal (instruction file only) or full (state, errors, and instruction files)
  • 14
    To skip the interactive prompts and use flags directly:
    15
    quasar init my-program \
      --yes \
      --template minimal \
      --test-language rust \
      --rust-framework quasar-svm \
      --toolchain solana
    
    16
    FlagOptionsDescription--templateminimal, fullAmount of boilerplate to generate--test-languagenone, rust, typescriptTest harness language--rust-frameworkquasar-svm, molluskRust test framework (when --test-language rust)--ts-sdkkit, web3.jsTypeScript SDK (when --test-language typescript)--toolchainsolana, upstreamBPF build toolchain--no-git—Skip git init and the initial commit--yes / -y—Skip all prompts; requires NAME as positional argument
    17
    Once scaffolding completes, change into the project directory:
    18
    cd my-program
    
    19
    Write Your Program
    20
    Open 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”:
    21
    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(())
        }
    }
    
    22
    What each part does:
    23
  • 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.
  • 24
    The has_one = authority constraint verifies that counter.authority == authority.key() at validation time — before your instruction body runs.
    25
    Build the Program
    26
    Compile the program to a .so BPF binary:
    27
    quasar build
    
    28
    Additional build flags:
    29
    # 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
    
    30
    The compiled binary lands in target/deploy/<crate-name>.so.
    31
    Run the Tests
    32
    quasar test
    
    33
    Useful test flags:
    34
    # 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
    
    35
    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.
    36
    Deploy to a Cluster
    37
    Deploy to the cluster configured in your Solana CLI (solana config get):
    38
    quasar deploy
    
    39
    Override the target cluster or keypair:
    40
    # 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
    
    41
    After deployment, sync your declare_id! with the on-chain address:
    42
    quasar keys sync
    

    Other Useful CLI Commands

    Once your project is running, the CLI offers several additional tools:
    # Add a new instruction handler, state account, or error enum
    quasar add --instruction transfer
    quasar add --state vault
    quasar add --error insufficient-funds
    
    # Generate the program IDL JSON
    quasar idl ./
    
    # Generate client code from the IDL
    quasar client target/idl/my_program.json --lang typescript
    
    # Measure compute-unit usage with a flamegraph
    quasar profile
    
    # Dump sBPF assembly for a specific function
    quasar dump --function increment
    
    # Remove build artifacts
    quasar clean
    quasar clean --all   # also runs cargo clean
    
    # Manage and inspect global CLI settings
    quasar config list
    quasar config get defaults.toolchain
    quasar config set defaults.toolchain solana
    
    # Audit the program surface for upgrade-safety issues
    quasar lint
    quasar lint --strict          # treat warnings as failures
    quasar lint --update-lock     # write current surface to quasar.lock.json
    
    # Generate shell completions (bash, zsh, fish, etc.)
    quasar completions bash >> ~/.bashrc
    quasar completions zsh  >> ~/.zshrc
    

    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.

    Build docs developers (and LLMs) love