Hey there, fellow crypto adventurer! Ready to dive into the world of Solana development? Whether you’re just starting out or you’re a seasoned dev looking to expand your toolkit, setting up the Solana Command Line Interface (CLI) is your gateway to the Solana ecosystem.
Let’s walk through the process together, with a little code magic and some handy tips along the way.
Before we jump into the setup, let’s take a moment to understand what the Solana CLI is and why it’s such a crucial tool for developers in the Solana ecosystem.
The Solana Command Line Interface (CLI) is a powerful toolset that allows you to interact directly with the Solana blockchain from your terminal. Whether you're managing wallets, deploying smart contracts (called programs in Solana), or querying the state of the blockchain, the CLI provides you with the commands needed to perform these tasks efficiently.
Here’s what you can do with the Solana CLI:
In short, the Solana CLI is your command center for all things Solana, enabling you to harness the full potential of the blockchain from a simple terminal interface. Now that we know what it is, let’s get started with setting it up!
Before we get our hands dirty with Solana, let’s make sure our environment is prepped and ready. Depending on your operating system, the installation process can vary a bit, but don’t worry—we’ve got you covered.
If you’re on Windows, you’ll need to install the Windows Subsystem for Linux (WSL). This essentially gives you a Linux environment within your Windows OS, making the rest of the setup process much smoother. Follow the official WSL installation guide from Microsoft, and once you’re done, you can skip ahead to the Linux section.
Linux users, you’re in luck! Most of the heavy lifting is already done. You just need to ensure a few dependencies are installed:
sudo apt-get update
sudo apt-get install -y curl build-essential pkg-config libudev-dev llvm libclang-dev protobuf-compiler
Mac users, your journey begins with installing Rust. But first, let’s get Homebrew (if you haven’t already):
/bin/bash -c "$(curl -fsSL <https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh>)"
Once Homebrew is up and running, install the necessary dependencies:
brew install rust pkg-config libudev protobuf llvm coreutils
Solana programs are written in Rust, so getting Rust set up is the next step. Rust’s installation is a breeze thanks to rustup
, the recommended installation method.
Open your terminal and run:
curl --proto '=https' --tlsv1.2 -sSf <https://sh.rustup.rs> | sh -s -- -y
After a successful installation, reload your environment to include Cargo’s bin directory in your PATH:
source $HOME/.cargo/env
To confirm Rust is good to go, check the installed version:
rustc --version
You should see something like:
rustc 1.80.1 (3f5fd8dd4 2024-09-02)
With Rust in place, it’s time to bring the Solana CLI into the spotlight. The CLI is packed with tools to build, deploy, and manage Solana programs.
Run this command to install the Solana CLI:
sh -c "$(curl -sSfL <https://release.anza.xyz/stable/install>)"
For first-time installations, you might get a prompt to add the Solana CLI to your PATH. If you do, simply follow the instructions:
export PATH="/Users/yourusername/.local/share/solana/install/active_release/bin:$PATH"
And verify the installation:
solana --version
You should see output like:
solana-cli 1.18.22 (src:9efdd74b; feat:4215500110, client:Agave)
Anchor simplifies Solana program development with its powerful framework. Let’s install it:
cargo install --git <https://github.com/coral-xyz/anchor> --tag v0.30.1 anchor-cli
To confirm that Anchor CLI is installed correctly:
anchor --version
You should see:
anchor-cli 0.30.1
For running Anchor’s default test files (especially if you’re diving into TypeScript), you’ll need Node.js and Yarn.
Linux/Mac Users can install Node.js and Yarn via Homebrew:
brew install node
brew install yarn
With the Solana CLI installed, let’s familiarize ourselves with some basic commands.
To view your current configuration:
solana config get
Expect output like this:
Config File: /Users/test/.config/solana/cli/config.yml
RPC URL: <https://api.mainnet-beta.solana.com>
WebSocket URL: wss://api.mainnet-beta.solana.com/ (computed)
Keypair Path: /Users/test/.config/solana/id.json
Commitment: confirmed
You can set the cluster to work on different networks:
solana config set --url devnet
Other clusters include:
solana config set --url mainnet-beta
solana config set --url localhost
solana config set --url testnet
Let’s create a wallet to interact with the Solana network:
solana-keygen new
Keep your seed phrase safe, and once generated, view your wallet’s public key:
solana address
To fund your wallet with some SOL on the devnet:
solana config set -ud
solana airdrop 2
Check your balance:
solana balance
For local testing, start a Solana validator:
solana-test-validator
Don’t forget to set your CLI config to localhost:
solana config set -ul
And that’s it! You’ve successfully installed the Solana CLI and set up your environment for Solana development. Now, whether you’re planning to deploy the next big dApp or just want to explore Solana’s blockchain, you’re equipped with all the tools you need. Happy coding!
But before you wrap things up and get ready to deploy something cool on Solana Mainnet, there’s one crucial step you shouldn’t skip—security!
Make sure to get your project audited by a reliable firm like QuillAudits, known for thorough and reliable blockchain security services. If you’re looking for a faster, AI-driven option, consider using QuillShield, an AI agent that not only finds vulnerabilities but also solves them.
And the best part? You can get an AI audit from QuillShield for free! Stay safe and secure as you launch your next big project.
Get Pure Alpha Straight to Your Inbox. Miss this, and you’re missing out.
Insider Secrets - Delivered Right to You. Subscribe now.