Skip to content

feat: add Quasar framework variants for all examples#557

Open
mikemaccana-edwardbot wants to merge 25 commits intosolana-developers:mainfrom
mikemaccana:quasar-examples
Open

feat: add Quasar framework variants for all examples#557
mikemaccana-edwardbot wants to merge 25 commits intosolana-developers:mainfrom
mikemaccana:quasar-examples

Conversation

@mikemaccana-edwardbot
Copy link
Copy Markdown
Contributor

@mikemaccana-edwardbot mikemaccana-edwardbot commented Apr 12, 2026

Summary

Adds Quasar framework variants for every Anchor example in the repo — 48 programs total.

Quasar is a zero-copy, no_std Solana program framework by Blueshift. It provides Anchor-compatible ergonomics (#[program], #[account], #[derive(Accounts)]) with significantly lower compute unit overhead and tiny program sizes (3-55 KB vs Anchor's 150-500 KB).

Examples added

basics/ (15)

hello-solana, counter, transfer-sol, checking-accounts, create-account, program-derived-addresses, pda-rent-payer, account-data, close-account, favorites, processing-instructions, realloc, repository-layout, rent, cross-program-invocation

tokens/ (10)

create-token, transfer-tokens, escrow, pda-mint-authority, token-fundraiser, spl-token-minter, nft-minter, nft-operations, token-swap, external-delegate-token-master

tokens/token-2022/ (12)

basics, cpi-guard, default-account-state, group, immutable-owner, interest-bearing, memo-transfer, metadata, mint-close-authority, non-transferable, permanent-delegate, transfer-fee

tokens/token-2022/transfer-hook/ (7)

hello-world, counter, account-data-as-seed, transfer-cost, transfer-switch, whitelist, allow-block-list-token

compression/ (3)

cnft-burn, cnft-vault, cutils

oracles/ (1)

pyth

CI

Includes .github/workflows/solana-quasar.yml — follows the same pattern as the Native and Pinocchio workflows (detect **/quasar/** changes, install quasar CLI, quasar build + cargo test).

Structure

Each quasar/ directory is a standalone Cargo project with:

  • src/lib.rs — program entrypoint
  • src/instructions/ — one file per instruction
  • src/tests.rs — Rust tests using quasar-svm
  • Auto-generated client crate from quasar build

Key techniques used

  • quasar-spl for SPL Token and Token-2022 CPI (transfer, mint_to, close_account, etc.)
  • quasar-spl metadata feature for Metaplex Token Metadata CPI
  • Raw invoke()/invoke_signed() for Bubblegum, SPL Account Compression, and Token-2022 extensions
  • Manual syscall access (sol_secp256k1_recover) for Ethereum signature verification
  • String<P, N> and Vec<T, P, N> dynamic types for variable-length account data

@mikemaccana-edwardbot mikemaccana-edwardbot changed the title feat: add Quasar framework variants for basics examples feat: add Quasar framework variants for all examples Apr 12, 2026
Add Quasar framework implementations alongside existing Anchor, native,
and Pinocchio variants for three basic examples:

- hello-solana: logs a greeting and the program ID
- counter: initialize + increment with PDA-derived state
- transfer-sol: CPI transfer via system program + direct lamport manipulation

Each is a standalone Cargo project (not in root workspace) with:
- Program source using quasar-lang macros
- Auto-generated client crate via quasar build
- Tests using quasar-svm

All examples build with 'quasar build' and pass 'quasar test'.
Follows the same pattern as solana-native.yml and solana-pinocchio.yml:
- Detects changed **/quasar/** directories
- Matrix strategy for parallel builds
- Installs quasar CLI from git
- Runs quasar build + cargo test (pure Rust, no JS/pnpm)
- Skipped beta channel (Quasar CLI pins its own Solana toolchain)
All 5 examples build and pass tests with quasar-lang 0.0.0:

- basics/account-data/quasar — PDA with multiple String<u8, 50> fields
- basics/close-account/quasar — create + close account with String field
- basics/favorites/quasar — fixed (u64) + dynamic (String) field mixing
- basics/processing-instructions/quasar — String instruction args, no state
- basics/realloc/quasar — auto-realloc via set_inner with String field

These demonstrate Quasar's dynamic type system:
- String<P, N> marker types in #[account] structs (becomes &'a str)
- String in #[instruction] args (u32-prefixed wire format, becomes &str)
- set_inner() for writing dynamic fields with auto-realloc
- Manual instruction data encoding in tests (quasar-svm framework)
create-token: mint creation and minting (no Metaplex metadata)
transfer-tokens: mint_to and transfer SPL token operations
escrow: full make/take/refund with PDA vault, has_one checks, close

All three build with quasar build and pass cargo test.
pda-mint-authority: PDA as mint authority with signed minting
token-fundraiser: crowdfunding with initialize, contribute, check, refund

Both build with quasar build and pass cargo test.
Port the token examples that were skipped by the previous subagent:

1. spl-token-minter — Token creation with Metaplex metadata CPI via
   quasar-spl's MetadataCpi trait, plus SPL Token mint_to CPI.

2. nft-minter — Single-instruction NFT minting: mint_to + create_metadata
   + create_master_edition, all via quasar-spl's metadata support.

3. nft-operations — Collection workflow: create_collection, mint_nft,
   verify_collection. Uses PDA authority with invoke_signed for all
   Metaplex CPIs. Uses verify_sized_collection_item.

4. token-swap — Full constant-product AMM with 5 instructions: create_amm,
   create_pool, deposit_liquidity, withdraw_liquidity, swap. Pure integer
   math (no fixed-point crate needed). Integer sqrt via Newton's method.

5. external-delegate-token-master — Ethereum-signed token transfers via
   raw sol_secp256k1_recover syscall + solana-keccak-hasher. Avoids
   solana-secp256k1-recover crate (pulls std via thiserror).

Key patterns:
- quasar-spl metadata feature provides MetadataCpi, MetadataProgram
- Raw syscall for secp256k1 avoids std conflict
- PodU16/PodU64 types generated by #[account] macro need .get()/.into()
- Quasar seeds resolve field names to addresses, not account data fields

All examples build (cargo build-sbf) and tests pass (cargo test).
Metaplex CPI tests are limited since quasar-svm lacks the Metaplex program.
Token Extensions examples ported using quasar-spl's TokenInterface
and InterfaceAccount types for Token-2022 compatibility.

Examples: basics, cpi-guard, default-account-state, group,
immutable-owner, interest-bearing, memo-transfer, metadata,
mint-close-authority, non-transferable, permanent-delegate,
transfer-fee
Transfer hook examples ported: hello-world, counter, account-data-as-seed,
transfer-cost, transfer-switch, whitelist.

allow-block-list-token skipped (most complex, multi-program interaction).
Compression examples (cnft-burn, cnft-vault, cutils) ported using raw
invoke()/invoke_signed() for Bubblegum and SPL Account Compression CPI,
matching the approach used in the Anchor versions.

Oracle example (pyth) ported with manual PriceUpdateV2 account data
parsing in Quasar's no_std environment.
Port the ABL (Allow/Block List) token transfer hook program from Anchor
to Quasar. This program enforces allow/block lists on Token-2022 transfers.

All 7 instructions ported:
- init_mint: Creates Token-2022 mint with transfer hook, permanent delegate,
  metadata pointer, and embedded metadata (AB mode + threshold)
- init_config: Creates config PDA with authority
- attach_to_mint: Attaches transfer hook to an existing mint
- tx_hook: SPL transfer hook execute handler with allow/block/threshold logic
- init_wallet: Creates per-wallet allow/block entries
- remove_wallet: Removes wallet entries (closes PDA)
- change_mode: Changes mode via Token-2022 metadata update

Key Quasar patterns:
- Raw CPI for Token-2022 extension init (TransferHook, PermanentDelegate,
  MetadataPointer, InitializeMint2, TokenMetadata)
- Manual TLV parsing of Token-2022 metadata in tx_hook for mode detection
- ExtraAccountMetaList with AccountData seed (destination owner lookup)
- Direct lamport manipulation for account closing (remove_wallet)
- 8-byte instruction discriminators (required by SPL transfer hook interface)

Builds with quasar build (54.5 KB). State unit tests pass.
All 15 basics examples refactored to use free functions instead of
impl methods on Accounts structs. Pattern: handle_{method_name}(accounts, ...)
replaces self.method_name(...) on impl blocks.
All tokens examples (escrow, create-token, transfer-tokens, nft-minter,
nft-operations, spl-token-minter, token-swap, token-fundraiser,
external-delegate-token-master, pda-mint-authority) refactored.

For escrow: disambiguated handle_withdraw_tokens_and_close using
module-qualified paths (take:: and refund::) since both Take and Refund
had methods with the same name.
…unctions

All compression examples (cnft-burn, cnft-vault, cutils) and
oracles (pyth) refactored. Pyth lib.rs call site updated though the
instruction file itself is missing (pre-existing incomplete example).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants