Development Environment Setup
Install all required tools and configure your Solana development environment.
Prerequisites
Before setting up your Solana development environment, ensure your system meets the following requirements. Solana development is supported on macOS, Linux, and Windows (via WSL2). A modern machine with at least 8GB RAM is recommended for running a local validator.
Installing Rust
Solana programs are written in Rust. Install Rust using the official installer:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
rustup component add rustfmt clippyInstalling the Solana CLI
The Solana CLI provides tools for deploying programs, managing wallets, and interacting with the network:
# Install Solana CLI (latest stable)
sh -c "$(curl -sSfL https://release.solana.com/stable/install)"
# Add to PATH (add to ~/.bashrc or ~/.zshrc)
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
# Verify installation
solana --versionInstalling Anchor Framework
Anchor is the most widely used framework for Solana program development. It abstracts away much of the boilerplate and provides safety checks:
# Install Anchor Version Manager (AVM)
cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
# Install and use the latest Anchor version
avm install latest
avm use latest
# Verify
anchor --versionSetting Up a Wallet
# Generate a new keypair
solana-keygen new --outfile ~/.config/solana/id.json
# Set the default keypair
solana config set --keypair ~/.config/solana/id.json
# Configure for devnet
solana config set --url devnet
# Request airdrop (devnet only)
solana airdrop 2JavaScript/TypeScript Setup
# Install Node.js (v18+ recommended)
# Using nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
nvm install 20
nvm use 20
# Install Solana Web3.js
npm install @solana/web3.js
# Install Anchor client library
npm install @coral-xyz/anchorLocal Validator
For development, run a local Solana validator to test without network latency:
# Start local test validator
solana-test-validator
# In another terminal, configure CLI to use localhost
solana config set --url localhost
# Check validator status
solana cluster-version--snapshot-interval-slots flag.Recommended IDE Setup
Visual Studio Code with the following extensions provides the best Solana development experience: rust-analyzer for Rust code intelligence, Solana Snippets for common patterns, and Even Better TOML for Cargo.toml files.