Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

quicknode/solana-program-examples

Open more actions menu
 
 

Repository files navigation

Quicknode Solana Program Examples

A fork of the Solana Foundation program examples with current versions, more programs, and additional frameworks.

Anchor Quasar Pinocchio Native ASM

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 with pnpm test as defined in Anchor.toml.
  • 💫 Quasar — a newer, more performant framework with Anchor-compatible ergonomics. Run pnpm test to execute tests.
  • 🤥 Pinocchio — a zero-copy, zero-allocation library for Solana programs. Run pnpm test to execute tests.
  • 🦀 Native Rust — vanilla Rust using Solana's native crates. Run pnpm test to execute tests.
  • 🧬 ASM — hand-written sBPF assembly built with the sbpf toolchain. Run pnpm build-and-test to build and 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.

Financial Software

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.

⚓ Anchor 💫 Quasar 🦀 Native

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.

⚓ Anchor

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.

⚓ Anchor 💫 Quasar

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.

⚓ Anchor 💫 Quasar

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.

⚓ Anchor

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 in incoming instructions meet specific criteria.

⚓ Anchor 💫 Quasar 🤥 Pinocchio 🦀 Native 🧬 ASM

Close Account

Close an account and reclaim its lamports.

⚓ Anchor 💫 Quasar 🤥 Pinocchio 🦀 Native

Create Account

Create new accounts on the blockchain.

⚓ Anchor 💫 Quasar 🤥 Pinocchio 🦀 Native 🧬 ASM

Cross-Program Invocation

Call one program from another — the hand program invokes the lever program to toggle a switch.

⚓ Anchor 💫 Quasar 🦀 Native

PDA Rent Payer

Use a PDA to pay rent for creating a new account.

⚓ Anchor 💫 Quasar 🤥 Pinocchio 🦀 Native

Processing Instructions

Add parameters to an instruction handler and use them.

⚓ Anchor 💫 Quasar 🤥 Pinocchio 🦀 Native

Program Derived Addresses

Store and retrieve state using PDAs as deterministic account addresses.

⚓ Anchor 💫 Quasar 🤥 Pinocchio 🦀 Native

Realloc

Handle accounts that need to grow or shrink in size.

⚓ Anchor 💫 Quasar 🤥 Pinocchio 🦀 Native

Rent

Calculate an account's size to determine the minimum rent-exempt balance.

⚓ Anchor 💫 Quasar 🤥 Pinocchio 🦀 Native

Repository Layout

Structure a larger Solana program across multiple files and modules.

⚓ Anchor 💫 Quasar 🦀 Native

Transfer SOL

Send SOL between two accounts.

⚓ Anchor 💫 Quasar 🤥 Pinocchio 🦀 Native 🧬 ASM

Pyth Price Feeds

An oracle brings real-world market prices — a dollar, a stock, a token — onchain, like a Bloomberg terminal feeding live quotes. Pyth publishes low-latency prices from institutional sources, each in its own price feed account. This example reads a feed and logs its price, confidence interval, and exponent — the building block an AMM, lending market, or vault uses to value assets.

⚓ Anchor 💫 Quasar

Tokens

Create Token

Create a token mint with a symbol and icon.

⚓ Anchor 💫 Quasar 🦀 Native

Mint NFT

Mint an NFT from inside your own program using the Token and Metaplex Token Metadata programs.

⚓ Anchor 💫 Quasar 🦀 Native

NFT Operations

Create an NFT collection, mint NFTs, and verify NFTs as part of a collection using Metaplex Token Metadata.

⚓ Anchor 💫 Quasar

Token Minter

Mint tokens from inside your own program using the Classic Token Program.

⚓ Anchor 💫 Quasar 🦀 Native

Transfer Tokens

Transfer tokens between accounts.

⚓ Anchor 💫 Quasar 🦀 Native

PDA Mint Authority

Mint tokens using a PDA as the mint authority, so your program controls token issuance.

⚓ Anchor 💫 Quasar 🦀 Native

External Delegate Token Master

Control token transfers using an external secp256k1 delegate signature.

⚓ Anchor 💫 Quasar

Token Extensions

Basics

Create token mints, mint tokens, and transfer tokens using Token Extensions.

⚓ Anchor 💫 Quasar

CPI Guard

Prevent certain token actions from occurring within cross-program invocations.

⚓ Anchor 💫 Quasar

Default Account State

Create new token accounts that are frozen by default.

⚓ Anchor 💫 Quasar 🦀 Native

Group Pointer

Create tokens that belong to larger groups using the Group Pointer extension.

⚓ Anchor 💫 Quasar

Immutable Owner

Create token accounts whose owning program cannot be changed.

⚓ Anchor 💫 Quasar

Interest Bearing Tokens

Create tokens that show an interest calculation, updating their displayed balance over time.

⚓ Anchor 💫 Quasar

Memo Transfer

Require all transfers to include a descriptive memo.

⚓ Anchor 💫 Quasar

Onchain Metadata

Store metadata directly inside the token mint account, without needing additional programs.

⚓ Anchor

NFT Metadata Pointer

Create an NFT using the metadata pointer extension, storing onchain metadata (including custom fields) inside the mint.

⚓ Anchor

Mint Close Authority

Allow a designated account to close a token mint.

⚓ Anchor 💫 Quasar 🦀 Native

Multiple Extensions

Use multiple Token Extensions on a single mint at once.

🦀 Native

Non-Transferable Tokens

Create tokens that cannot be transferred between accounts.

⚓ Anchor 💫 Quasar 🦀 Native

Permanent Delegate

Create tokens that remain under the control of a designated account, even when transferred elsewhere.

⚓ Anchor 💫 Quasar

Transfer Fee

Create tokens with a built-in transfer fee.

⚓ Anchor 💫 Quasar 🦀 Native

Transfer Hook — Hello World

A minimal transfer hook that executes custom logic on every token transfer.

⚓ Anchor 💫 Quasar

Transfer Hook — Counter

Count how many times tokens have been transferred.

⚓ Anchor 💫 Quasar

Transfer Hook — Account Data as Seed

Use token account owner data as seeds to derive extra accounts in a transfer hook.

⚓ Anchor 💫 Quasar

Transfer Hook — Allow/Block List

Restrict or allow token transfers using an onchain list managed by a list authority.

⚓ Anchor 💫 Quasar

Transfer Hook — Transfer Cost

Charge an additional fee on every token transfer.

⚓ Anchor 💫 Quasar

Transfer Hook — Transfer Switch

Enable or disable token transfers with an onchain switch.

⚓ Anchor 💫 Quasar

Transfer Hook — Whitelist

Restrict transfers so only whitelisted accounts can receive tokens.

⚓ Anchor 💫 Quasar

Compression

cNFT Burn

Burn compressed NFTs.

⚓ Anchor 💫 Quasar

cNFT Vault

Store Metaplex compressed NFTs inside a PDA.

⚓ Anchor 💫 Quasar

Compression Utilities

Work with Metaplex compressed NFTs.

⚓ Anchor 💫 Quasar


PRs welcome! Follow the contributing guidelines and see CHANGELOG.md for release history.

About

A repository of Solana program examples

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Rust 71.7%
  • TypeScript 14.2%
  • C# 8.1%
  • ShaderLab 3.1%
  • JavaScript 0.9%
  • Assembly 0.6%
  • Other 1.4%
Morty Proxy This is a proxified and sanitized view of the page, visit original site.