Introducing a new way to review your PRs.

Read the announcement

solana-foundation / program-examples

A repository of Solana program examples

View on GitHub

19 documents · Updated Nov 23, 2026

overview

Knowledge Base updated: 2026-11-22

Solana Program Examples

This repository is a collection of standalone Solana program examples. Examples are organized by domain and commonly provide parallel implementations using native Rust, Pinocchio, or Anchor, with TypeScript clients and tests.

The main areas are foundational account/program patterns, SPL Token and Token-2022 workflows, compressed assets, cryptographic primitives, games, and oracle integrations. Program state and behavior live within each example's on-chain program directory; clients and tests demonstrate instruction construction and expected flows.

System map

flowchart TD
  Repo[program-examples repository] --> Basics[basics]
  Repo --> Tokens[tokens]
  Repo --> Compressed[compressed assets]
  Repo --> Crypto[cryptography]
  Repo --> Games[games]
  Repo --> Oracles[oracles]

  Basics --> Accounts[Account lifecycle examples]
  Basics --> Instructions[Instruction and CPI examples]
  Basics --> PDAs[PDA examples]

  Tokens --> Core[Core token operations]
  Tokens --> Token2022[Token-2022 extensions]
  Tokens --> NFT[NFT and Merkle flows]
  Tokens --> Exchange[Escrow, swaps, fundraising]

  Compressed --> CNFT[Compressed NFT lifecycle]
  Compressed --> Vaults[Compressed asset vaults]

Glossary

  • Pinocchio: a low-level Solana program-development framework used by many example variants.
  • PDA: a program-derived address, deterministically derived from seeds and a program ID.
  • CPI: cross-program invocation, where one on-chain program invokes another program's instruction.
  • Token-2022: the extensible SPL Token program whose mint and token-account extensions alter account and instruction requirements.
  • State compression: Solana's Merkle-tree-backed representation for compressed assets such as compressed NFTs.

Invariants

  • A program must validate the accounts and signer privileges it relies on before mutating state or invoking another program; see the account-checking and instruction-processing patterns under basics/checking-accounts/** and basics/processing-instructions/**.
  • PDA authority flows must derive and use the same seed and bump inputs for address validation and signed invocation; see basics/program-derived-addresses/** and basics/pda-rent-payer/**.
  • Account allocation changes must account for rent, ownership, and safe initialization or closure; see basics/create-account/**, basics/realloc/**, and basics/close-account/**.
  • Token-2022 extensions require extension-aware mint/token-account setup and compatible instruction paths; see tokens/token-2022/**.
  • Multi-party token custody flows must constrain settlement to their stated authority and condition checks; see tokens/escrow/**.

Routing table