Example Programs
Example Anchor programs references
There are extensive examples for individual Anchor features on the Solana Foundation Program Examples repo.
Additionally, the Quicknode Solana Program Examples repo includes Anchor examples of larger programs, like order books, loan markets, betting markets, and so on. The current Anchor stack, including Anchor 1.x, the multiple files layout, and LiteSVM for tests is used throughout.
Basics
| Example | Description |
|---|---|
| checking-accounts | Checking account example with Anchor |
| close-account | Close account example with Anchor |
| counter | Counter program using Anchor |
| create-account | Create accounts with Anchor |
| cross-program-invocation | Cross program invocation with Anchor |
| favorites | Store user "favorites" with Anchor |
| hello-solana | Basic "Hello, Solana!" program with Anchor |
| pda-rent-payer | PDA rent payer example with Anchor |
| processing-instructions | Process instructions using Anchor |
| program-derived-addresses | Program-derived addresses with Anchor |
| realloc | Reallocate account data with Anchor |
| rent | Calculate account SOL rent with Anchor |
| transfer-sol | Transfer SOL tokens with Anchor |
Tokens
| Example | Description |
|---|---|
| create-token | Create an SPL token with Anchor |
| escrow | Escrow program using Anchor |
| nft-minter | Mint NFTs using Anchor |
| nft-operations | NFT operations with Anchor |
| pda-mint-authority | PDA as mint authority with Anchor |
| spl-token-minter | SPL token minting with Anchor |
| token-fundraiser | Token fundraiser using Anchor |
| token-swap | Swap tokens with Anchor |
| transfer-tokens | Transfer SPL tokens using Anchor |
Token Extensions
| Example | Description |
|---|---|
| basics | Basics of Token 2022 with Anchor |
| cpi-guard | CPI guard example with Anchor |
| default-account-state | Default account state setup with Anchor |
| group | Token grouping example with Anchor |
| immutable-owner | Immutable owner setup with Anchor |
| interest-bearing | Interest-bearing tokens using Anchor |
| memo-transfer | Memo transfer with Anchor |
| metadata | Token metadata with Anchor |
| mint-close-authority | Mint close authority with Anchor |
| multiple-extensions | Multiple extensions example with Anchor |
| nft-meta-data-pointer | NFT metadata pointer with Anchor |
| non-transferable | Non-transferable tokens using Anchor |
| permanent-delegate | Permanent delegate setup with Anchor |
| transfer-fee | Transfer fees example with Anchor |
| transfer-hook | Transfer hook example with Anchor |