Skip to content

quiknode-labs/solana-program-examples

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

589 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

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

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.

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

Automated Market Maker

Constant product AMM (xΒ·y=k) β€” create liquidity pools, deposit and withdraw liquidity, swap tokens with fees and slippage protection.

βš“ Anchor πŸ’« Quasar

Escrow

Peer-to-peer OTC trade β€” one user deposits token A and specifies how much token B they want. A counterparty fulfils the offer and both sides receive their tokens atomically.

βš“ Anchor πŸ’« Quasar πŸ¦€ Native

Token Fundraiser

Create a fundraiser specifying a target mint and amount. Contributors deposit tokens until the goal is reached.

βš“ Anchor πŸ’« Quasar

Pyth Price Feeds

Read offchain price data onchain using the Pyth oracle network.

βš“ Anchor πŸ’« Quasar

Basics

Hello Solana

A minimal program that logs a greeting.

βš“ Anchor πŸ’« Quasar πŸ€₯ Pinocchio πŸ¦€ Native

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

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

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

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

SPL Token Minter

Mint tokens from inside your own program using the 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 to keep things consistent.

About

A repository of Solana program examples

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Rust 63.7%
  • TypeScript 21.1%
  • C# 9.2%
  • ShaderLab 3.6%
  • HLSL 0.6%
  • Shell 0.6%
  • Other 1.2%