Setting Up Local Solana Environment

realacjoshua

RealACJoshua

Posted on November 26, 2024

Setting Up Local Solana Environment

Hello and welcome! In this guide, we'll explore how to set up a development environment for Solana. Whether you're diving into blockchain for the first time or transitioning from another platform, this guide will help you get started. Let's go!


Step 1: Setting Up WSL

To get started, we’ll use Windows Subsystem for Linux (WSL). WSL lets you run Linux commands directly on your Windows machine, which is essential for Solana development.

Install WSL:

  1. Open PowerShell and run:
wsl --install
Enter fullscreen mode Exit fullscreen mode
  1. If WSL is already installed, update it:
wsl --update
Enter fullscreen mode Exit fullscreen mode
  1. Install Ubuntu (or any Linux distribution you prefer):
wsl --install -d Ubuntu
Enter fullscreen mode Exit fullscreen mode
  1. Reboot your computer and open Ubuntu:
wsl ubuntu
Enter fullscreen mode Exit fullscreen mode
  1. Set up your Ubuntu environment by creating a username and password.

Step 2: Installing Rust

Rust is the primary language for Solana development. Let's install it:

  1. Run the following commands:
sudo apt update
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
Enter fullscreen mode Exit fullscreen mode
  1. Reload the PATH environment variable:
. "$HOME/.cargo/env"
Enter fullscreen mode Exit fullscreen mode
  1. Verify the installation:
rustc --version
Enter fullscreen mode Exit fullscreen mode

You should see something like rustc 1.80.1.


Step 3: Installing the Solana CLI

The Solana CLI is essential for building and deploying Solana programs.

  1. Install the Solana CLI tool suite:
sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)"
Enter fullscreen mode Exit fullscreen mode
  1. Add the PATH environment variable:
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
Enter fullscreen mode Exit fullscreen mode
  1. Verify the installation:
solana --version
Enter fullscreen mode Exit fullscreen mode

Example output: solana-cli 1.18.22.


Step 4: Installing Anchor CLI

Anchor simplifies Solana program development.

  1. Install required dependencies:
sudo apt-get install -y build-essential pkg-config libudev-dev llvm libclang-dev protobuf-compiler libssl-dev
Enter fullscreen mode Exit fullscreen mode
  1. Install the Anchor Version Manager (AVM):
cargo install --git https://github.com/coral-xyz/anchor avm --force
Enter fullscreen mode Exit fullscreen mode
  1. Use AVM to install the latest Anchor CLI:
avm install latest
avm use latest
Enter fullscreen mode Exit fullscreen mode
  1. Verify the installation:
anchor --version
Enter fullscreen mode Exit fullscreen mode

Example output: anchor-cli 0.30.1.


Step 5: Installing Node.js and Yarn

Node.js and Yarn are required for running default Anchor project tests.

  1. Install Node Version Manager (nvm):
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
Enter fullscreen mode Exit fullscreen mode
  1. Restart your terminal and confirm the installation:
command -v nvm
Enter fullscreen mode Exit fullscreen mode
  1. Install Node.js:
nvm install node
Enter fullscreen mode Exit fullscreen mode

Verify the installation:

node --version
Enter fullscreen mode Exit fullscreen mode
  1. Install Yarn:
npm install --global yarn
Enter fullscreen mode Exit fullscreen mode

Verify the installation:

yarn --version
Enter fullscreen mode Exit fullscreen mode

Conclusion

Congratulations! You’ve successfully set up your Solana development environment. If you’re using Linux, skip Step 1. Ready to dive deeper into Solana? Subscribe and check out my upcoming posts for project ideas and advanced tips.

💖 💪 🙅 🚩
realacjoshua
RealACJoshua

Posted on November 26, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Setting Up Local Solana Environment