Program Examples
Onchain program examples for :anchor: Anchor :crab: Native Rust, and :snake: Python
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.
Using this repo
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 && anchor deploy
to build & deploy the program. Run anchor run test
to test it.
native
- Written using Solana's native Rust crates and vanilla Rust. Use cicd.sh
to build & deploy the program. Run yarn run test
to test it.
seahorse
- Written using the Seahorse framework, which converts your Python code to Anchor Rust. Use seahorse build && anchor deploy
to build & deploy the program. Run anchor run test
to test it.
If a given example is missing, please add it!
The example projects!
basics
account-data
anchor, native
checking-accounts
anchor, native
close-account
anchor, native
counter
anchor, native, seahorse
create-account
anchor, native
cross-program-invocation
anchor, native
favorites
anchor
hello-solana
anchor, native, seahorse
pda-rent-payer
anchor, native
processing-instructions
anchor, native
program-derived-addresses
anchor, native
realloc
anchor, native
rent
anchor, native
repository-layout
anchor, native
transfer-sol
anchor, native, seahorse
tokens
create-token
anchor, native
escrow
anchor
nft-minter
anchor, native
pda-mint-authority
anchor, native
spl-token-minter
anchor, native
token-swap
anchor
transfer-tokens
anchor, native, seahorse
tokens/token-2022
basics
anchor
cpi-guard
anchor
default-account-state
anchor, native
group
anchor
immutable-owner
anchor
interest-bearing
anchor
memo-transfer
anchor
metadata
anchor
mint-close-authority
anchor, native
multiple-extensions
native
non-transferable
anchor, native
permanent-delegate
anchor
transfer-fee
anchor, native
compression
cnft-burn
anchor
cnft-vault
anchor
cutils
anchor
oracles
pyth
anchor, seahorse
Examples We'd Love to See!
- Examples needed for Native:
- Examples needed for Anchor:
- Additional Accounts & Resolving Accounts
- Examples needed for Seahorse
- Any existing example missing a
seahorse
folder
- New examples needed for Anchor, Native, Solidity & Seahorse:
- Token lending
- Token swapping
- Escrow
- Staking
- Wrapped tokens
- Pyth
- Clockwork
- VRF
- Any oracle
- Merkle trees (compression)