Development Environment

Module 1: Setting Up Your BSV Development Environment

This module guides you through setting up your development environment for BSV blockchain development. The setup differs depending on whether you're building backend services or frontend dApps.


Universal Prerequisites

Required for both paradigms:

  • Computer running Windows, macOS, or Linux

  • Basic command line knowledge

  • Text editor or IDE (VS Code recommended)

  • Node.js 18+ and npm


Part 1: Universal Setup (Both Paradigms)

Step 1: Install Node.js

The BSV TypeScript SDK requires Node.js version 18 or higher.

macOS

# Using Homebrew
brew install node

# Verify installation
node --version  # Should be v18.0.0 or higher
npm --version

Windows

  1. Download installer from nodejs.orgarrow-up-right (LTS version)

  2. Run the installer

  3. Verify in Command Prompt:

Linux (Ubuntu/Debian)

Step 2: Install TypeScript

Step 3: Set Up Your IDE

We recommend Visual Studio Code for TypeScript development:

  1. Install these essential extensions:

    • ESLint: Code quality and linting

    • Prettier: Automatic code formatting

    • TypeScript Import Sorter: Organize imports

    • GitLens: Git integration and history

VS Code Settings

Create .vscode/settings.json in your project:

Step 4: Install BSV SDK

Step 5: Configure TypeScript

Create tsconfig.json:


Part 2A: Backend/Service Development Setup

For custodial applications where you control private keys

Backend Project Structure

Install Backend Dependencies

Environment Variables (Backend)

Create .env file:

⚠️ Security Warning:

  • Never store production private keys in .env files

  • Use HSM (Hardware Security Module) or key vaults in production

  • Always encrypt private keys at rest

  • Use strong access controls

Backend Test File

Create src/index.ts:

Backend NPM Scripts

Update package.json:

Test Backend Setup


Part 2B: Frontend/dApp Development Setup

For non-custodial applications using WalletClient

Frontend Project Structure (React Example)

Install Frontend Dependencies

Frontend Test Component

Create src/components/WalletTest.tsx:

Update App.tsx

Frontend NPM Scripts

package.json (already configured by Create React App):

Test Frontend Setup

MetaNet Desktop Wallet Installation (BSV Desktop)

Required for frontend development:

What is BSV Desktop? BSV Desktop (formerly MetaNet Desktop Wallet) is a modern wallet designed to make your experience with BSV Blockchain simple, secure, and powerful—whether you're a beginner or an advanced user. It's the standard wallet for BSV application development.

Download and Setup:

  1. Visit: https://desktop.bsvb.tech/

  2. Download for your OS (Windows, macOS, or Linux)

  3. Run the installer and follow the setup wizard

  4. Create a new wallet or import existing one

  5. Switch to testnet mode for development (Settings → Network → Testnet)

Getting BSV for Development:

Key Features for Developers:

  • Multi-network support (mainnet/testnet switching)

  • App integration for blockchain applications

  • Welcome gift: 99,991 Satoshis to start exploring

  • Advanced security with phone-based recovery

  • Identity Key and Private Key management for app integration

Your dApp will connect to this wallet via WalletClient

Complete Onboarding Guide:

  • https://hub.bsvblockchain.org/demos-and-onboardings/onboardings/onboarding-catalog/metanet-desktop-mainnet

Documentation:

  • Wallet Toolbox API: https://fast.brc.dev/

  • BRC Standards: https://hub.bsvblockchain.org/brc

  • Tech Stack & Resources: https://hub.bsvblockchain.org/bsv-skills-center


Part 3: Testing Your Setup

Backend Test

Expected Output:

Frontend Test

Expected Behavior:

  1. Browser opens at http://localhost:3000

  2. Click "Connect MetaNet Desktop Wallet"

  3. Wallet popup appears

  4. Authorize connection

  5. See "✅ Wallet connected successfully!"

  6. Public key displayed (truncated for security)


Additional Tools

Block Explorers

WhatsOnChain:

  • Mainnet: https://whatsonchain.com/

  • Testnet: https://test.whatsonchain.com/

Usage:

  • View transactions by TXID

  • Check address balances

  • Explore blocks and network stats

  • Debug transaction issues

Getting Testnet BSV

Get free testnet BSV for development:

  • Use MetaNet Desktop Wallet's built-in faucet feature

  • Join BSV Discordarrow-up-right to request testnet coins from the community

  • Use for testing without real funds

API Documentation

  • BSV SDK Docs: https://bsv-blockchain.github.io/ts-sdk/

  • Wallet Toolbox Reference: https://fast.brc.dev/

  • BRC Standards: https://hub.bsvblockchain.org/brc


Environment Variables Best Practices

Backend (.env)

Frontend (.env)

Security Rules:

  • ✅ Always add .env to .gitignore

  • ✅ Use different .env files for dev/prod

  • ✅ Never commit private keys

  • ✅ Use environment variables for all secrets

  • ✅ In backend production, use HSM or key vaults


Troubleshooting

"Cannot find module '@bsv/sdk'"

"WalletClient connection failed"

Checklist:

  • ✅ MetaNet Desktop Wallet installed?

  • ✅ Wallet unlocked?

  • ✅ Testnet mode if using testnet?

  • ✅ dApp origin authorized in wallet?

Solution:

TypeScript Errors

Permission Errors (Linux/macOS)

Port Already in Use


Verification Checklist

Backend Development Ready

  • ✅ Node.js 18+ installed

  • ✅ TypeScript 5.0+ installed

  • ✅ BSV SDK installed

  • ✅ Project structure created

  • ✅ Test script runs successfully

  • .env file configured

  • ✅ Git initialized

Frontend Development Ready

  • ✅ Node.js 18+ installed

  • ✅ React project created

  • ✅ BSV SDK installed

  • ✅ MetaNet Desktop Wallet installed

  • ✅ Wallet connection test works

  • ✅ Test component renders

  • ✅ Git initialized


Next Steps

Now that your environment is ready, continue to:

For Both Paradigms:

Then Choose Your Path:

Backend Developers:

Frontend Developers:


Official Documentation

Tools

Community


Your development environment is now ready! Let's learn BSV fundamentals.

Last updated