Solana Program Examples
Working, tested, up-to-date examples of common Solana programs - maintained by Quicknode
Install / Use
npx skills add quicknode/solana-program-examplesInstalls into whichever agent you are using.
README
Solana Program Examples

Solana program examples ('smart contracts') in Anchor, Quasar, Pinocchio, native Rust, and sBPF assembly. Focused on financial software ('DeFi'), plus the basics, tokens, Token Extensions, state compression, and more.
Working, tested, up-to-date examples of common Solana programs (what other chains call smart contracts), maintained by Quicknode. Current as of July 2026 (see CHANGELOG.md): every example builds and passes CI on Anchor 1.1, the current multi-file program layout (one file per instruction handler, account type, etc), and LiteSVM tests rather than the older solana-test-validator / web3.js stack.
Each example is available in one or more of the following frameworks:
- ⚓ Anchor - the most popular framework for Solana development. Build with
anchor build, test withanchor test. - 💫 Quasar - a newer, more performant framework with Anchor-compatible ergonomics. Build with
quasar build, test withquasar test. - 🤥 Pinocchio - a zero-copy, zero-allocation library for Solana programs. Build with
cargo build-sbf --manifest-path=./program/Cargo.toml, test withcargo test --manifest-path=./program/Cargo.toml. - 🦀 Native Rust - vanilla Rust using Solana's native crates. Build with
cargo build-sbf --manifest-path=./program/Cargo.toml, test withcargo test --manifest-path=./program/Cargo.toml. - 🧬 ASM - hand-written sBPF assembly built with the
sbpftoolchain. Build withsbpf build, test withcargo test.
[!NOTE] You don't need to write your own program for basic tasks like creating accounts, transferring SOL, or minting tokens. These are handled by existing programs like the System Program and Token Program.
Getting started
You need Rust, Solana CLI, Anchor, and pnpm installed. Clone the repo and cd into any example directory, then run its tests with the command for that framework (shown above) - for an Anchor example, anchor test. pnpm is used for repo-wide formatting and linting, not for running an example's tests.
To deploy to mainnet or devnet you'll need an RPC endpoint. Quicknode provides free and paid Solana endpoints - create one and set it as your cluster in Anchor.toml or with solana config set --url <your-endpoint>.
Financial software ("DeFi")
The programs are examples of common financial primitives on Solana. As well as tests these all have formal verification using Kani. Every finance program ships with proofs that verify its money-math invariants exhaustively over all inputs. See each program's kani-proofs/ directory for the harnesses and what they prove.
Escrow
Start here - the best first finance program to learn on Solana. A neutral account that holds funds until both sides deliver, like a real-estate escrow or a lawyer's trust account. The maker deposits token A and names how much token B they want; when a taker supplies token B, the program swaps both in a single all-or-nothing transaction. This swap is the core idea behind every onchain exchange.
🎬 Video: Build a Solana program (smart contract) in 30 minutes
Lending
A borrow/lend market like Solend or Kamino: suppliers deposit a token and receive share tokens whose exchange rate rises as borrowers pay interest, borrowers post those shares as collateral to draw a different token against it up to a loan-to-value limit, and liquidators close part of any position that crosses its health threshold. Interest accrues through a utilization-based rate curve and a cumulative index, so no per-account accrual loop is needed.
Order Book based Exchange
A typical NYSE/NASDAQ-style order book-based exchange. Buyers post bids (the price they'll pay), sellers post asks (the price they'll accept), and a trade happens when a bid and an ask meet. The exchange operator collects fees from trading. Similar to popular Solana exchanges like Openbook and Phoenix.
🎬 Video: How to make a crypto exchange on Solana
AMM based Exchange
An exchange with no order book: swaps fill instantly against a shared liquidity pool funded by liquidity providers, who earn a cut of the trading fees. Prices are set algorithmically by the pool's balances. Anyone can create a pool, add or remove liquidity, and swap tokens, with slippage protection on every trade. Similar to Solana exchanges like Raydium and Orca.
Prop AMM
A proprietary AMM: a market-making firm funds a venue with its own capital and quotes both sides of it, selling the base token at the oracle price plus a spread and buying it back at the oracle price minus the spread. No pricing curve, no liquidity providers, no pool shares: the operator is the only capital in the market, can re-quote or pull its quotes at will, and earns the spread instead of a fee. Because the price comes from an oracle rather than the pool's balances, trades have no price impact and nothing to sandwich. This is the design behind venues like Lifinity, SolFi, and HumidiFi, which fill most Solana swap volume through Jupiter routing.
Vault Strategy
A managed investment fund onchain, like an ETF or mutual fund. Investors deposit USDC for shares, a manager allocates the pool across a basket of assets (here, stocks like TSLAx and NVDAx), and each share's value tracks the fund's net asset value. The manager earns a management fee, and investors redeem a proportional slice of the underlying assets.
Betting Market
Parimutuel (pooled) prediction market - an admin opens an event with multiple outcomes, bettors stake tokens on an outcome, and at settlement the losing pool (minus a protocol fee) is split among winners in proportion to their stake.
🎬 Video: How to build a PolyMarket/Kalshi style betting market on Solana
Perpetual Futures
A perpetual futures exchange: a venue for making leveraged bets on an asset's price without ever owning the asset. Traders post collateral and open a long (betting the price rises) or short (betting it falls) sized up to several times their collateral; their profit or loss tracks the price move and is paid in the collateral token. Rather than matching buyers to sellers, every trade is against a shared liquidity pool that other users fund and that is the counterparty to all of it: the pool pays winners and keeps losers' collateral, and its providers earn the trading and funding fees in return. The price comes from an oracle, positions accrue a funding fee over time, and anyone can liquidate a position whose collateral can no longer cover its loss. This is the design behind venues like Jupiter Perpetuals and GMX.
Token Fundraiser
Onchain crowdfunding, like Kickstarter or GoFundMe. A creator sets a target amount in a chosen token, and contributors deposit into the fundraiser's account until the goal is reached.
Single concept examples
Hello Solana
A minimal program that logs a greeting.
⚓ Anchor 💫 Quasar 🤥 Pinocchio 🦀 Native 🧬 ASM
Account Data
Store and retrieve data using Solana accounts.
⚓ Anchor 💫 Quasar 🤥 Pinocchio 🦀 Native
Counter
Use a PDA to store global state - a counter that increments when called.
⚓ Anchor 💫 Quasar 🤥 Pinocchio 🦀 Native
Favorites
Save and update per-user state, ensuring users can only modify their own data.
⚓ Anchor 💫 Quasar 🤥 Pinocchio 🦀 Native
Checking Accounts
Validate that accounts provided i
Related Skills
clawhub
385.5kSearch ClawHub for skills when a requested capability is not already available; install, verify, update, uninstall, publish, or sync skills.
coding-agent
385.5kDelegate coding work to Codex, Claude Code, or OpenCode as background workers; not simple edits or read-only code lookup.
taskflow
385.5kCoordinate multi-step detached tasks as one durable TaskFlow job with owner context, state, waits, and child tasks.
agent-tui
106.4kMain Agents: Do NOT use this skill directly. If you need to test the TUI, invoke the `tui_tester` subagent. Drive terminal UI (TUI) applications programmatically for testing, automation, and inspection
