Setting up a Solana development environment for the first time can feel overwhelming. Between Rust, the Solana CLI, Anchor, and various testing tools, there are many moving parts. This guide walks you through the complete setup process, from zero to deploying your first program on devnet.
Prerequisites
Before you start, you'll need:
- A computer running macOS, Linux, or Windows (WSL2 recommended for Windows)
- Basic command-line familiarity
- A text editor (VS Code recommended)
- At least 10GB of free disk space
Windows users: Solana development works best on Linux. If you're on Windows, install WSL2 (Windows Subsystem for Linux) first. Run wsl --install in PowerShell as administrator, then do everything else inside the WSL terminal.
Step 1: Install Rust
Solana programs are written in Rust (or C, but practically everyone uses Rust). Install Rust using rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Follow the prompts and select the default installation. After installation, load the environment:
source $HOME/.cargo/env
Verify the installation:
rustc --version
cargo --version
You should see Rust 1.75+ (the latest stable version). Solana typically requires a recent stable Rust release.
VS Code Rust Extension
If you're using VS Code, install the rust-analyzer extension. It provides code completion, inline error checking, and go-to-definition for Rust code. This is essentially mandatory for a productive Rust development experience.
Step 2: Install Solana CLI
The Solana CLI (Command Line Interface) is your primary tool for interacting with the Solana network — deploying programs, managing wallets, and checking account state.
sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)"
Add Solana to your PATH (the installer usually prompts you to do this):
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
Add that line to your ~/.bashrc or ~/.zshrc so it persists.
Verify:
solana --version
Configure for Devnet
Set your CLI to point at devnet for development:
solana config set --url devnet
You can also use localhost (for local validator), testnet, or mainnet-beta. For development, devnet is the default choice.
Create a Wallet
Generate a new keypair for development:
solana-keygen new --outfile ~/.config/solana/devnet.json
solana config set --keypair ~/.config/solana/devnet.json
This creates a file-system wallet. Never use this keypair for real funds. It's for development only.
Get Devnet SOL
You need SOL to deploy programs and pay for transactions on devnet:
solana airdrop 5
If the public faucet is rate-limited (which happens frequently), you can use alternative faucets:
Check your balance:
solana balance
Step 3: Install Anchor
Anchor is the dominant framework for Solana program development. It provides a Rust framework for writing programs, a CLI for building and deploying, and a TypeScript client library for testing and frontend integration.
Install Anchor CLI
The recommended way to install Anchor is through avm (Anchor Version Manager):
cargo install --git https://github.com/coral-xyz/anchor avm --force
avm install latest
avm use latest
Verify:
anchor --version
Why Anchor?
You can write Solana programs in raw Rust using the solana-program crate, but Anchor dramatically reduces boilerplate:
- Account validation: Anchor generates account validation code from declarative macros, eliminating a major source of security bugs.
- Serialization: Automatic Borsh serialization/deserialization for accounts and instruction data.
- Error handling: Typed errors with meaningful messages instead of raw error codes.
- IDL generation: Automatically generates an Interface Definition Language file that TypeScript clients can consume.
- Testing framework: Built-in support for TypeScript-based integration tests.
For context, a simple program that would be 200+ lines in raw Rust might be 50 lines with Anchor.
Step 4: Install Node.js
You'll need Node.js for Anchor's TypeScript testing framework and for building frontend applications:
curl -fsSL https://fnm.vercel.app/install | bash
fnm install 20
fnm use 20
Verify:
node --version
npm --version
You can also use nvm instead of fnm — either works fine.
Install Yarn (Anchor projects use Yarn by default):
npm install -g yarn
Step 5: Create Your First Anchor Project
Now let's create a project and verify everything works:
anchor init my-first-program
cd my-first-program
This generates a project structure:
my-first-program/
├── Anchor.toml # Project configuration
├── Cargo.toml # Rust workspace
├── programs/
│ └── my-first-program/
│ ├── Cargo.toml # Program dependencies
│ └── src/
│ └── lib.rs # Program code
├── tests/
│ └── my-first-program.ts # TypeScript tests
├── app/ # Frontend (optional)
└── migrations/
└── deploy.ts
Understanding the Generated Code
Open programs/my-first-program/src/lib.rs:
use anchor_lang::prelude::*;
declare_id!("your_program_id_here");
#[program]
pub mod my_first_program {
use super::*;
pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
msg!("Greetings from: {:?}", ctx.program_id);
Ok(())
}
}
#[derive(Accounts)]
pub struct Initialize {}
This is a minimal Anchor program with one instruction (initialize) that logs a message.
Build the Program
anchor build
The first build takes a few minutes as it downloads and compiles dependencies. Subsequent builds are faster. The compiled program (a .so file) lands in target/deploy/.
Run Tests
Anchor can run a local Solana validator and execute your tests against it:
anchor test
This command:
- Starts a local validator (
solana-test-validator)
- Builds your program
- Deploys it to the local validator
- Runs the TypeScript tests in
tests/
- Shuts down the validator
If tests pass, your environment is set up correctly.
Step 6: Local Validator
For faster development iteration, you can run a persistent local validator:
solana-test-validator
This starts a local Solana node on http://localhost:8899. In a separate terminal:
solana config set --url localhost
solana airdrop 100 # unlimited SOL on local
The local validator is instant, free, and resets when restarted. It's ideal for rapid testing.
Loading Programs on Local Validator
You can clone programs from mainnet onto your local validator for testing integrations:
solana-test-validator \
--clone TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA \
--clone TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb \
--url mainnet-beta
This clones the SPL Token and Token-2022 programs from mainnet, letting you test token operations locally.
Step 7: Essential VS Code Extensions
Complete your development environment with these VS Code extensions:
- rust-analyzer: Rust language support (essential)
- Even Better TOML: Syntax highlighting for Cargo.toml files
- Error Lens: Inline error messages (highly recommended)
- Solana Explorer: View accounts and transactions from VS Code
Deploying to Devnet
Once your program works locally, deploy to devnet:
# Ensure you're on devnet
solana config set --url devnet
# Build
anchor build
# Deploy
anchor deploy
After deployment, you can view your program on Solana Explorer or Solscan by searching for the program ID.
Upgrade Your Program
Solana programs are upgradeable by default. To deploy a new version:
anchor build
anchor deploy
Anchor handles the upgrade process automatically, replacing the program code while keeping the same program ID.
Common Issues and Solutions
"Insufficient funds" on devnet
Devnet faucets have rate limits. Wait a few minutes between airdrop requests, or use a web-based faucet. You need about 3-5 SOL for deploying a typical program.
Build failures with Rust version
Anchor and Solana require specific Rust versions. If you get version-related errors:
rustup update stable
rustup default stable
"Account not found" or "Program not found"
Make sure your CLI is pointing at the right network:
solana config get
The RPC URL should match where you deployed.
Local validator port conflicts
If port 8899 is in use, specify an alternative:
solana-test-validator --rpc-port 8999
Next Steps
With your environment set up, here's where to go next:
- Learn Anchor: The Anchor documentation covers accounts, instructions, CPIs, and common patterns.
- Study examples: The Anchor examples repository contains programs of varying complexity.
- Build something: Start with a simple counter program, then move to a CRUD app, then try interacting with existing programs (SPL Token, Jupiter).
- Explore APIs: When building frontends, you'll want an enhanced API provider. Check out our comparison of Solana API providers.
- Browse developer tools: See what tools other Solana developers use in our Developer Tools category.
Final Thoughts
The Solana development toolchain has improved dramatically over the past two years. Anchor handles most of the low-level complexity, the CLI is reliable, and testing with the local validator is fast.
The biggest hurdle is usually the Rust learning curve, not the Solana-specific tooling. If you're new to Rust, spend time with the Rust Book alongside Solana development — the investment pays off quickly.
Your development environment is the foundation for everything you'll build. Take the time to set it up properly, configure your editor, and understand the workflow. Once you're comfortable building, testing, and deploying locally, moving to devnet and eventually mainnet is straightforward.
FAQ
Do I need to know Rust to build on Solana?
For writing on-chain programs, yes — Rust is the standard language. However, if you're building frontend applications or bots that interact with existing programs, you can use TypeScript with libraries like @solana/web3.js and @coral-xyz/anchor without writing any Rust.
How much disk space does the Solana development environment require?
Expect to use about 5-10GB total: Rust toolchain (~3GB), Solana CLI (~1GB), and compiled program artifacts (~1-5GB depending on project size). The local validator's ledger grows over time but resets when you restart it.
Can I develop Solana programs on Windows without WSL?
Technically some tools work natively on Windows, but the experience is significantly worse. Many Solana and Anchor commands assume a Unix environment. WSL2 provides a seamless Linux environment within Windows and is strongly recommended.
Devnet is for development — it resets periodically and has a faucet for free SOL. Testnet is used for validator testing and stress testing and is less stable. Use devnet for application development. Only use mainnet-beta (real SOL) when you're ready for production.