> ## Documentation Index
> Fetch the complete documentation index at: https://solana.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> This page is part of the Solana developer documentation at https://solana.com/developers/docs. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get the page as Markdown.
> Index of all pages: https://solana.com/llms.txt. Per-section indexes such as https://solana.com/developers/docs/payments/llms.txt are smaller; prefer them when working on one task.
> Coding agents: install the official Solana skill for current APIs and conventions with `npx skills add https://github.com/solana-foundation/solana-dev-skill` (also served at https://solana.com/SKILL.md).
> Code in the cookbook and task pages comes from tested example files. Prefer it over writing API calls from memory.

# Program Examples

> A list of Solana program examples in different languages and frameworks, which can help you learn and use as reference for your own projects.

The
[Solana Program Examples](https://github.com/solana-foundation/program-examples)
repository on GitHub offers several subfolders, each containing code examples to
help developers learn and experiment with Solana blockchain development.

You can find the examples in the `solana-foundation/program-examples` together
with README files that explain you how to run the different examples. Most
examples are self-contained and available in one or more of
[Anchor](https://www.anchor-lang.com/docs/installation),
[Pinocchio](https://github.com/anza-xyz/pinocchio), and native Rust.

Within the repo you will find the following subfolder, each with assorted
example programs within them:

- [Basics](#basics)
- [Tokens](#tokens)
- [Token-2022 extensions](#token-2022-extensions)

There are also [ecosystem program examples](#ecosystem-solana-program-examples)

## Basics

Contains a series of examples that demonstrate the foundational steps for
building Solana programs using native Rust libraries. These examples are
designed to help developers understand the core concepts of Solana programming.

| Example Name                                                                                                                  | Description                                                                                                             | Language                             |
| ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
| [Account Data](https://github.com/solana-foundation/program-examples/tree/main/basics/account-data)                           | Saving an address with name, house number, street, and city in an account.                                               | Native, Anchor, Pinocchio            |
| [Checking Accounts](https://github.com/solana-foundation/program-examples/tree/main/basics/checking-accounts)                 | Security lessons that shows how to do account checks                                                                    | Native, Anchor, Pinocchio            |
| [Close Account](https://github.com/solana-foundation/program-examples/tree/main/basics/close-account)                         | Show you how to close accounts to get its rent back.                                                                    | Native, Anchor, Pinocchio            |
| [Counter](https://github.com/solana-foundation/program-examples/tree/main/basics/counter)                                     | A simple counter program in all the different architectures.                                                            | Native, Anchor, Pinocchio, mpl-stack |
| [Create Account](https://github.com/solana-foundation/program-examples/tree/main/basics/create-account)                       | How to create a system account within a program.                                                                        | Native, Anchor, Pinocchio            |
| [Cross-program invocation](https://github.com/solana-foundation/program-examples/tree/main/basics/cross-program-invocation)   | Using a hand and lever analogy this shows you how to call another program from within a program.                        | Native, Anchor, Pinocchio            |
| [hello solana](https://github.com/solana-foundation/program-examples/tree/main/basics/hello-solana)                           | Hello world example which just prints hello world in the transaction logs.                                              | Native, Anchor, Pinocchio            |
| [Pda Rent payer](https://github.com/solana-foundation/program-examples/tree/main/basics/pda-rent-payer)                       | Shows you how you can use the lamports from a PDA to pay for a new account.                                             | Native, Anchor, Pinocchio            |
| [Processing Instructions](https://github.com/solana-foundation/program-examples/tree/main/basics/processing-instructions)     | Shows you how to handle instruction data string and u32.                                                                | Native, Anchor, Pinocchio            |
| [Program-derived addresses](https://github.com/solana-foundation/program-examples/tree/main/basics/program-derived-addresses) | Shows how to use seeds to refer to a PDA and save data in it.                                                           | Native, Anchor, Pinocchio            |
| [Realloc](https://github.com/solana-foundation/program-examples/tree/main/basics/realloc)                                     | Shows how to resize an existing account within the [runtime limits](/developers/docs/core/accounts/modification-rules#data-rules). | Native, Anchor, Pinocchio            |
| [Repository Layout](https://github.com/solana-foundation/program-examples/tree/main/basics/repository-layout)                 | Recommendations on how to structure your program layout.                                                                | Native, Anchor, Pinocchio            |
| [Transfer SOL](https://github.com/solana-foundation/program-examples/tree/main/basics/transfer-sol)                           | Different methods of transferring SOL for system accounts and PDAs.                                                     | Native, Anchor, Pinocchio, Seahorse  |

## Tokens

Most tokens on Solana use the Solana Program Library (SPL) token standard. Here
you can find many examples on how to mint, transfer, burn tokens, and even how to
interact with them in programs.

| Example Name                                                                                                    | Description                                                                                        | Language                  |
| --------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | ------------------------- |
| [Create Token](https://github.com/solana-foundation/program-examples/tree/main/tokens/create-token)             | How to create a token and add metaplex metadata to it.                                             | Anchor, Native, Pinocchio |
| [NFT Minter](https://github.com/solana-foundation/program-examples/tree/main/tokens/nft-operations)             | Minting only one amount of a token and then removing the mint authority.                           | Anchor, Native, Pinocchio |
| [PDA Mint Authority](https://github.com/solana-foundation/program-examples/tree/main/tokens/pda-mint-authority) | Shows you how to change the mint authority of a mint, to mint tokens from within a program.        | Anchor, Native, Pinocchio |
| [Token Swap](https://github.com/solana-foundation/program-examples/tree/main/tokens/token-swap)                 | Extensive example that shows you how to build an AMM (automated market maker) pool for SPL tokens. | Anchor                    |
| [Transfer Tokens](https://github.com/solana-foundation/program-examples/tree/main/tokens/transfer-tokens)       | Shows how to transfer SPL token using CPIs into the token program.                                 | Anchor, Native, Pinocchio |
| [Token-2022](https://github.com/solana-foundation/program-examples/tree/main/tokens/token-2022)                 | See Token-2022 extensions.                                                                 | Anchor, Native, Pinocchio |

## Token-2022 extensions

Token-2022 is a new standard for tokens on Solana. It is a more flexible and
lets you add 16 different extensions to a token mint to add more functionality
to it. A full list of the extensions can be found in the
[Getting Started Guide](/developers/docs/tokens/extensions)

| Example Name                                                                                                                     | Description                                                                                                       | Language                  |
| -------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | ------------------------- |
| [Basics](https://github.com/solana-foundation/program-examples/tree/main/tokens/token-2022/basics/anchor)                        | How to create a token, mint, and transfer it.                                                                      | Anchor                    |
| [Default account state](https://github.com/solana-foundation/program-examples/tree/main/tokens/token-2022/default-account-state) | This extension lets you create token accounts with a certain state, for example frozen.                           | Anchor, Native, Pinocchio |
| [Mint Close Authority](https://github.com/solana-foundation/program-examples/tree/main/tokens/token-2022/mint-close-authority)   | With the old token program it was not possible to close a mint. Now it is.                                        | Anchor, Native, Pinocchio |
| [Multiple Extensions](https://github.com/solana-foundation/program-examples/tree/main/tokens/token-2022/multiple-extensions)     | Shows you how you can add multiple extensions to a single mint                                                    | Native, Pinocchio         |
| [NFT Metadata pointer](https://github.com/solana-foundation/program-examples/tree/main/tokens/token-2022/nft-meta-data-pointer)  | It is possible to use the metadata extension to create NFTs and add dynamic onchain metadata.                    | Anchor                    |
| [Not Transferable](https://github.com/solana-foundation/program-examples/tree/main/tokens/token-2022/non-transferable)           | Useful for example for achievements, referral programs, or any soul bound tokens.                                  | Anchor, Native, Pinocchio |
| [Transfer fee](https://github.com/solana-foundation/program-examples/tree/main/tokens/token-2022/transfer-fee)                   | Every transfer of the tokens hold some tokens back in the token account which can then be collected.              | Anchor, Native, Pinocchio |
| [Transfer Hook](https://github.com/solana-foundation/program-examples/tree/main/tokens/token-2022/transfer-hook)                 | Four examples to add additional functionality to your token using a CPI from the token program into your program. | Anchor                    |

## Ecosystem Solana program examples

Third parties often maintain their own libraries of example Solana programs.
These are maintained by the providers rather than by Solana Foundation.

- [Quicknode's Solana Program Examples](https://github.com/quicknode/solana-program-examples)
  provides additional programs, particularly for financial software, for both
  newer Anchor versions and the Quasar framework.
