---
title: Solana Cookbook
seoTitle: Solana Cookbook - Code examples for Solana development
description:
  "The Solana Cookbook is a collection of code snippets, useful examples, and
  references for building on Solana."
---

The Solana Cookbook is a developer resource that provides examples and
references for building applications on Solana. Each example and reference will
focus on specific aspects of Solana development while providing additional
details and usage examples.

## Development Guides

Development guides help developers set up and interact with the Solana ecosystem
using various tools and clients.

| Guide                                                                                                   | Client     | Description                                |
| ------------------------------------------------------------------------------------------------------- | ---------- | ------------------------------------------ |
| [How to Start a Local Validator](/developers/cookbook/development/start-local-validator)                | Solana CLI | Set up and run a local Solana validator    |
| [Connecting to a Solana Environment](/developers/cookbook/development/connect-environment)              | web3.js    | Connect to different Solana networks       |
| [Getting Test SOL](/developers/cookbook/development/test-sol)                                           | web3.js    | Obtain SOL tokens for testing              |
| [Subscribing to Events](/developers/cookbook/development/subscribing-events)                            | web3.js    | Listen to Solana program events            |
| [Using Mainnet Accounts and Programs](/developers/cookbook/development/using-mainnet-accounts-programs) | Solana CLI | Work with production accounts and programs |

## Wallet Management

Learn how to create, restore, and manage Solana wallets using various tools and
libraries.

| Guide                                                                                          | Client         | Description                         |
| ---------------------------------------------------------------------------------------------- | -------------- | ----------------------------------- |
| [How to Create a Keypair](/developers/cookbook/wallets/create-keypair)                         | web3.js        | Generate new Solana keypairs        |
| [How to Restore a Keypair](/developers/cookbook/wallets/restore-keypair)                       | web3.js        | Recover existing keypairs           |
| [How to Verify a Keypair](/developers/cookbook/wallets/verify-keypair)                         | web3.js        | Validate keypair authenticity       |
| [How to Validate a Public Key](/developers/cookbook/wallets/check-publickey)                   | web3.js        | Check public key validity           |
| [How to Generate Mnemonics for Keypairs](/developers/cookbook/wallets/generate-mnemonic)       | bip39          | Create seed phrases                 |
| [How to Restore a Keypair from a Mnemonic](/developers/cookbook/wallets/restore-from-mnemonic) | web3.js, bip39 | Recover keypairs using seed phrases |
| [How to Generate a Vanity Address](/developers/cookbook/wallets/generate-vanity-address)       | Solana CLI     | Create custom addresses             |
| [How to Sign and Verify a Message](/developers/cookbook/wallets/sign-message)                  | web3.js        | Message signing and verification    |
| [How to Connect a Wallet with React](/developers/cookbook/wallets/connect-wallet-react)        | React, web3.js | Integrate wallets in React apps     |

## Transaction Operations

Explore various transaction-related operations on the Solana blockchain.

| Guide                                                                                            | Client  | Description                    |
| ------------------------------------------------------------------------------------------------ | ------- | ------------------------------ |
| [How to Send SOL](/developers/cookbook/transactions/send-sol)                                    | web3.js | Transfer SOL between accounts  |
| [How to Send Tokens](/developers/cookbook/transactions/send-tokens)                              | web3.js | Transfer SPL tokens            |
| [How to Calculate Transaction Cost](/developers/cookbook/transactions/calculate-cost)            | web3.js | Estimate transaction fees      |
| [How to Add a Memo to a Transaction](/developers/cookbook/transactions/add-memo)                 | web3.js | Include memos in transactions  |
| [How to Add Priority Fees to a Transaction](/developers/cookbook/transactions/add-priority-fees) | web3.js | Set transaction priorities     |
| [How to Optimize Compute Requested](/developers/cookbook/transactions/optimize-compute)          | web3.js | Improve transaction efficiency |
| [Offline Transactions](/developers/cookbook/transactions/offline-transactions)                   | web3.js | Handle offline operations      |

## Account Management

Learn how to manage Solana accounts effectively.

| Guide                                                                                  | Client        | Description                |
| -------------------------------------------------------------------------------------- | ------------- | -------------------------- |
| [How to Create an Account](/developers/cookbook/accounts/create-account)               | web3.js       | Create new Solana accounts |
| [How to Calculate Account Creation Cost](/developers/cookbook/accounts/calculate-rent) | web3.js       | Estimate account costs     |
| [How to Create a PDA's Account](/developers/cookbook/accounts/create-pda-account)      | web3.js, Rust | Work with PDAs             |
| [How to Sign with a PDA's Account](/developers/cookbook/accounts/sign-with-pda)        | Rust          | PDA signing operations     |
| [How to Close an Account](/developers/cookbook/accounts/close-account)                 | Rust          | Remove accounts            |
| [How to Get Account Balance](/developers/cookbook/accounts/get-account-balance)        | web3.js       | Check account balances     |

## Program Development

Develop Solana programs with these comprehensive guides.

| Guide                                                                                        | Client | Description                  |
| -------------------------------------------------------------------------------------------- | ------ | ---------------------------- |
| [How to Transfer SOL in a Solana Program](/developers/cookbook/programs/transfer-sol)        | Rust   | Program-based SOL transfers  |
| [How to Get Clock in a Program](/developers/cookbook/programs/clock)                         | Rust   | Access program clock         |
| [How to Change Account Size](/developers/cookbook/programs/change-account-size)              | Rust   | Modify account sizes         |
| [How to Do Cross Program Invocation](/developers/cookbook/programs/cross-program-invocation) | Rust   | CPI operations               |
| [How to Create a Program Derived Address](/developers/cookbook/programs/create-pda)          | Rust   | Generate PDAs                |
| [How to Read Accounts in a Program](/developers/cookbook/programs/read-accounts)             | Rust   | Account data access          |
| [Reading Multiple Instructions](/developers/cookbook/programs/read-multiple-instructions)    | Rust   | Handle multiple instructions |
| [How to Verify Accounts in a Solana Program](/developers/cookbook/programs/verify-accounts)  | Rust   | Account verification         |

## Token Operations

Comprehensive guides for working with tokens on Solana.

| Guide                                                                                                     | Client        | Description                    |
| --------------------------------------------------------------------------------------------------------- | ------------- | ------------------------------ |
| [How to Create a Token](/developers/cookbook/tokens/create-mint-account)                                  | web3.js       | Create new tokens              |
| [How to Get a Token Mint](/developers/cookbook/tokens/get-token-mint)                                     | web3.js       | Access token mints             |
| [How to Create a Token Account](/developers/cookbook/tokens/create-token-account)                         | web3.js       | Set up token accounts          |
| [How to Get a Token Account](/developers/cookbook/tokens/get-token-account)                               | web3.js       | Retrieve token accounts        |
| [How to Get a Token Account's Balance](/developers/cookbook/tokens/get-token-balance)                     | web3.js, rust | Check token balances           |
| [How to Mint Tokens](/developers/cookbook/tokens/mint-tokens)                                             | web3.js       | Create new tokens              |
| [How to Transfer Tokens](/developers/cookbook/tokens/transfer-tokens)                                     | web3.js       | Move tokens between accounts   |
| [How to Burn Tokens](/developers/cookbook/tokens/burn-tokens)                                             | web3.js       | Remove tokens from circulation |
| [How to Close Token Accounts](/developers/cookbook/tokens/close-token-accounts)                           | web3.js       | Clean up token accounts        |
| [How to Set Authority on Token Accounts or Mints](/developers/cookbook/tokens/set-update-token-authority) | web3.js       | Manage token permissions       |
| [How to Delegate Token Accounts](/developers/cookbook/tokens/approve-token-delegate)                      | web3.js       | Set up token delegation        |
| [How to Revoke a Token Delegate](/developers/cookbook/tokens/revoke-token-delegate)                       | web3.js       | Remove delegates               |
| [How to Use Wrapped SOL](/developers/cookbook/tokens/manage-wrapped-sol)                                  | web3.js       | Work with wrapped SOL          |
| [How to Get All Token Accounts by Authority](/developers/cookbook/tokens/get-all-token-accounts)          | web3.js       | List token accounts            |
| [How to Create an NFT](/developers/cookbook/tokens/create-nft)                                            | web3.js       | Mint NFTs                      |
| [How to Fetch the NFT Metadata](/developers/cookbook/tokens/fetch-nft-metadata)                           | Javascript    | Fetch NFT metadata             |
| [How to Get the Owner of an NFT](/developers/cookbook/tokens/get-nft-owner)                               | web3.js       | Find NFT ownership             |
| [How to Get All NFTs from a Wallet](/developers/cookbook/tokens/fetch-all-nfts)                           | web3.js       | List wallet NFTs               |
