# Dev Environment Setup

Get your local environment ready before writing code.

## Prerequisites

| Tool | Version | Install |
|------|---------|---------|
| Node.js | 20+ | `nvm install 20 && nvm use 20` |
| Rust | latest stable | `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \| sh` |
| Solana CLI | 3.x | `curl --proto '=https' --tlsv1.2 -sSfL https://solana-install.solana.workers.dev | bash` |
| Anchor | 1.0.0+ | `cargo install avm --git https://github.com/solana-foundation/anchor --locked && avm update` |

**Skill:** `compatibility-matrix` (official) — check exact version requirements for your stack

## Local Testing Environment

### Option A: Surfpool (recommended)

Drop-in replacement for `solana-test-validator` with sub-second startup and mainnet state cloning.

```bash
# macOS
brew install txtx/taps/surfpool

# Start local network
surfpool start
```

**Skills:** `surfpool` (official), `surfpool-cheatcodes` (official)

### Option B: solana-test-validator (standard)

```bash
solana-test-validator
# In another terminal:
solana config set --url localhost
```

## Devnet SOL

```bash
solana airdrop 5 --url devnet
# Or use the faucet: https://faucet.solana.com
```

## Environment Variables

Create `.env` in your project root:

```bash
# RPC (use Helius for production, devnet for development)
SOLANA_RPC_URL=https://api.devnet.solana.com
# HELIUS_RPC_URL=https://mainnet.helius-rpc.com/?api-key=YOUR_KEY

# Wallet (for backend/agent projects)
# PRIVATE_KEY=your-base58-private-key

# Colosseum Copilot (for competitive research)
# COLOSSEUM_COPILOT_PAT=your-copilot-token
```

## Verify Setup

```bash
solana --version          # Should show 3.x
anchor --version          # Should show 1.0.0+
node --version            # Should show 20+
solana config get         # Check RPC URL
solana balance            # Check devnet balance
```

## MCPs for Development

Configure in `.claude/settings.json`:

```json
{
  "mcpServers": {
    "helius": { "command": "npx", "args": ["helius-mcp@latest"] },
    "solana-fender": { "command": "cargo", "args": ["run", "--release"] }
  }
}
```

**MCPs:** `helius-mcp` (wallet data, transactions), `solana-fender-mcp` (program analysis)

## Sources

- Solana installation docs: https://solana.com/docs/intro/installation
- Anchor installation docs: https://www.anchor-lang.com/docs/installation
- npm package metadata for current Node requirements (for example `@solana/wallet-adapter-react`, `@solana/kit`)
