Local Dev Basics
9 examples to get you started with local Solana development - 6 basic and 3 intermediate.
Prerequisites
- Agave 4.1.1 / Solana CLI 3.0.10 installed
- Anchor 0.32.1 for program workflows (
avm use 0.32.1) - A funded keypair at
~/.config/solana/id.json
solana --version
anchor --versionBasic Examples
1. Start a Local Validator
Run an isolated cluster on your laptop.
solana-test-validator- Default RPC:
http://127.0.0.1:8899 - Ctrl+C stops the cluster - state is ephemeral unless you use ledger flags
- No rate limits or faucet throttling unlike devnet
Related: solana-test-validator - flags and lifecycle
2. Point CLI at Localnet
Route terminal commands to the local validator.
solana config set --url http://127.0.0.1:8899
solana slotslotshould advance every second while validator runs- Reset to devnet when finished:
solana config set --url devnet - Match this URL in
Anchor.tomlforanchor test
3. Fund Your Local Wallet
Use the local faucet for unlimited test SOL.
solana airdrop 10
solana balance- Local airdrops are generous for account rent experiments
- Same keypair works across localnet sessions if you restart validator with same ledger path
- Fees are still deducted - balance changes on transfers
Related: Airdrops & Balances - balance concepts
4. Build and Deploy Locally
Compile then deploy to the running validator.
anchor build
anchor deployanchor deployusesAnchor.tomlprovider URL- Program IDs come from
target/deploy/*-keypair.json - Redeploy upgrades when upgrade authority is retained
Related: Deploying Programs - deploy details
5. Run Anchor Tests
Integration test against embedded validator.
anchor test- Spins validator, deploys, runs TypeScript/Rust tests, tears down
- Logs appear in terminal - pair with Local Logs & Debugging
- Faster iteration than manual deploy + client send
6. Stream Logs Locally
Watch program output during tests.
solana logs- Run in a second terminal while invoking transactions
- Shows
msg!andsol_logoutput from your program - No provider WebSocket limits on localhost
Related: Logs & Debugging - CLI log tools
Intermediate Examples
7. Clone a Mainnet Account
Pull real on-chain state into localnet for realistic tests.
solana-test-validator --clone <ACCOUNT_PUBKEY> --url mainnet-beta- Validator fetches account data at startup from mainnet RPC
- Essential for testing against live AMM/oracle layouts
- Clone only accounts you need - startup time grows with count
Related: Cloning Mainnet Accounts - clone strategies
8. Load Programs from File
Deploy a compiled .so without full Anchor workspace deploy.
solana program deploy target/deploy/my_program.so \
--url http://127.0.0.1:8899- Useful for testing third-party program binaries
- Combine with clones to simulate mainnet CPI graphs
- Program keypair must match expected ID if clients hardcode it
Related: Loading Programs & Fixtures - seeding state
9. Choose Localnet vs Devnet
Pick the right cluster for the task at hand.
# Local: fast, deterministic
solana config set --url http://127.0.0.1:8899
# Shared: realistic networking, faucet limits
solana config set --url devnet- Localnet for unit/integration speed and CI
- Devnet for multi-team shared deployments and wallet demos
- See decision workflow page for full branching guide
Related: Localnet vs Devnet Workflow - when to use each
Stack versions: This page was written for Agave 4.1.1, Solana CLI 3.0.10, Anchor 0.32.1, anchor-lang 0.32.1, Rust 1.91.1, @solana/kit 7.0.0, Surfpool 0.12.0, and LiteSVM 0.6.x.