SkillAgentSearch skills...

Program Examples

A repository of Solana program examples

Install / Use

npx skills add solana-foundation/program-examples

Installs into whichever agent you are using.

About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Program Examples

Onchain program examples for ⚓ Anchor, 🤥 Pinocchio, and 🦀 Native Rust.

Anchor Pinocchio Native

This repo contains Solana onchain programs (referred to as 'Smart Contracts' in other blockchains).

[!NOTE] If you're new to Solana, you don't need to create your own programs to perform basic things like making accounts, creating tokens, sending tokens, or minting NFTs. These common tasks are handled with existing programs, for example the System Program (for making account or transferring SOL) or the token program (for creating tokens and NFTs). See the Solana Developer site to learn more.

⚠️ This repository uses pnpm as the default package manager.
Ensure pnpm is installed before running any examples.

Each folder includes examples for one or more of the following:

  • anchor - Written using Anchor, the most popular framework for Solana development, which uses Rust. Use anchor build and anchor deploy to build and deploy the program. Tests should be executed using pnpm test as defined in the Anchor.toml scripts section.

  • pinocchio - Written using Pinocchio, a zero-copy, zero-allocation library for Solana programs. Build and test commands are the same as native examples. Run pnpm test to execute tests.

  • native - Written using Solana's native Rust crates and vanilla Rust. Build and test commands are defined via pnpm scripts and use litesvm for testing. Run pnpm test to execute tests.

If a given example is missing, please send us a PR to add it! Our aim is to have every example available in every option. We'd also love to see more programs involving staking, wrapped tokens, oracles, compression and VRF. Follow the contributing guidelines to keep things consistent.

The example programs

Basics

Hello world

Hello World on Solana! A minimal program that logs a greeting.

anchor pinocchio native

Account-data

Store and retrieve data using Solana accounts.

anchor pinocchio native

Storing global state - Counter

Store global state in an account, making a counter that increments when called.

anchor pinocchio native

Saving per-user state - Favorites

Save and update per-user state on the blockchain, ensuring users can only update their own information.

anchor pinocchio native

Checking Instruction Accounts

Check that the accounts provided in incoming instructions meet particular criteria.

anchor pinocchio native

Closing Accounts

Close an account and get the Lamports back.

anchor pinocchio native

Creating Accounts

Make new accounts on the blockchain, calculating the necessary minimum rent from the account's size.

anchor pinocchio native

Cross program invocations

Invoke an instruction handler from one onchain program in another onchain program.

anchor native

PDA rent-payer

Use a PDA to pay the rent for the creation of a new account.

anchor pinocchio native

Processing instructions

Add parameters to an instruction handler and use them.

anchor pinocchio native

Storing date in program derived addresses

Store and retrieve state in Solana.

anchor pinocchio native

Handling accounts that expand in size

How to store state that changes size in Solana.

anchor pinocchio native

Laying out larger programs

Layout larger Solana onchain programs.

anchor native

Transferring SOL

Send SOL between two accounts.

anchor pinocchio native

Tokens

Creating tokens

Create a token on Solana with a token symbol and icon.

anchor pinocchio native

NFT operations

Create an NFT collection, mint NFTs, and verify NFTs as part of a collection using Metaplex Token Metadata. Reminder: you don't need your own program just to mint an NFT, see the note at the top of this README.

anchor pinocchio

Transferring Tokens

Create a token mint, mint tokens, and transfer tokens between accounts.

anchor pinocchio native

Allowing users to swap digital assets - Escrow

Allow two users to swap digital assets with each other, each getting 100% of what the other has offered due to the power of decentralization!

anchor pinocchio native

Fundraising with SPL Tokens

Create a fundraiser account specifying a target mint and amount, allowing contributors to deposit tokens until the goal is reached.

anchor

Distributing tokens with Merkle-proof claims

Fund a vault once, publish a Merkle root of a balance snapshot, and let each holder claim their allocation with a proof — the claim pattern behind large airdrops and chain migrations.

anchor

Minting a token from inside a program with a PDA as the mint authority

Mint a Token from inside your own onchain program using the Token program. Reminder: you don't need your own program just to mint an NFT, see the note at the top of this README.

anchor native pinocchio

Creating an Automated Market Maker

Create liquidity pools to allow trading of new digital assets and allows users that provide liquidity to be rewarded by creating an Automated Market Maker.

anchor

External delegate token master

Control token transfers using an external secp256k1 delegate signature.

anchor

Token Extensions

Basics - create token mints, mint tokens, and transfer tokens with Token Extensions

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

anchor

Preventing CPIs with CPI guard

Enable CPI guard to prevents certain token action from occurring within CPI (Cross-Program Invocation).

anchor

Using default account state

Create new token accounts that are frozen by default.

anchor native

Grouping tokens

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

anchor

Creating token accounts whose owner cannot be changed

Create tokens whose owning program cannot be changed.

anchor

Interest bearing tokens

Create tokens that show an 'interest' calculation.

anchor

Requiring transactions to include descriptive memos

Create tokens where transfers must have a memo describing the transaction attached.

anchor

Adding on-chain metadata to the token mint

Create tokens that store their onchain metadata inside the token mint, without needing to use or pay for additional programs.

[anchor](./tokens/token-2022/metadata

Related Skills

View on GitHub
GitHub Stars1.4k
CategoryDevelopment
Updated23h ago
Forks530

Languages

TypeScript

Security Score

100/100

Audited on Aug 7, 2026

No findings