Cross-program invocations (CPIs) let your program call instructions on other Solana programs — the System Program to create accounts, SPL Token to transfer tokens, or your own program for self-CPI events. Quasar provides two stack-only CPI builders that go directly to theDocumentation 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.
sol_invoke_signed_c syscall without heap allocation: CpiCall for calls with a fixed account count and CpiDynamic for variable-length calls.
CpiCall<N, D> — Const-Generic Fixed Builder
CpiCall is parameterized by the number of accounts N and the byte length of instruction data D. Both are known at compile time, so the entire struct lives on the stack:
Invocation Methods
| Method | When to use |
|---|---|
.invoke() | No PDA signers |
.invoke_signed(&seeds) | One PDA signer |
.invoke_with_signers(&[Signer]) | Multiple PDA signers |
.invoke_with_return() | No signers, read return data |
.invoke_signed_with_return(&seeds) | One signer, read return data |
CpiDynamic<MAX_N, MAX_D> — Runtime-Length Builder
When the account count or data size varies at runtime but is bounded by compile-time constants, use CpiDynamic. Accounts are pushed one at a time; data is set all at once. A compile-time assertion prevents the struct from exceeding the SVM’s 3 KiB safe stack budget:
Core CPI Types
All CPI-related types live inquasar_lang::cpi and are re-exported from solana-instruction-view:
InstructionAccount
Per-account metadata for the instruction: address + signer/writable flags. Constructed with helpers:
InstructionAccount::writable_signer(addr), InstructionAccount::writable(addr), InstructionAccount::readonly(addr), InstructionAccount::readonly_signer(addr).CpiAccount
Full account view passed to the runtime during the CPI. Built from an
&AccountView by cpi_account_from_view. Each CpiCall maintains a parallel array of these alongside the InstructionAccount metas.Seed / Signer
Seed wraps a &[u8] seed slice. Signer groups a slice of Seeds into one PDA signer entry. Build them from byte slices: Seed::from(b"escrow" as &[u8]).CpiSignerSeeds
Trait implemented by
[Seed<'_>; N] and [Seed<'_>]. Passed to .invoke_signed() — Quasar wraps the array in a Signer and passes it to the syscall.System Program CPI
Quasar ships built-in helpers for the most common System Program instructions:Program<SystemProgram> wrapper exposes the same helpers as methods, useful when you have the system program account in your accounts struct:
Handling Pre-funded Accounts
system::init_account handles both fresh accounts (zero lamports) and pre-funded PDAs (non-zero lamports) without the CreateAccount failure mode:
SPL Token CPI
Thequasar-spl crate provides zero-copy token account types and typed CPI helpers:
Reading Return Data
After a CPI call that sets return data, useinvoke_with_return() or invoke_signed_with_return() to capture and decode the result:
invoke_with_return() verifies that ret.program_id() matches the invoked program before returning. CpiReturn::decode<T> then checks that the data length equals size_of::<T::Zc>().
invoke_raw — Direct Syscall
For the lowest-level CPI control, call invoke_raw directly. This bypasses CpiCall’s type-safe wrappers and goes straight to sol_invoke_signed_c:
