Hello and welcome back!
In our last lesson, we built the foundation for our journey by setting up a complete Rust development environment using WSL2, rustup, cargo, and VS Code with rust-analyzer. You now have a professional-grade setup for writing and compiling Rust code.
Today, we'll build on that foundation by installing and configuring the Solana Command Line Interface (CLI). This tool is your primary interface for interacting with the Solana blockchain. Think of it as the equivalent of npm for the Node.js ecosystem or git for version control—it's a powerful and indispensable tool. By the end of this lesson, you will have installed the Solana CLI, configured it to connect to the developer network, created a wallet, and funded it with test tokens, making you ready to deploy and interact with on-chain programs.
What is the Solana CLI?
Before we install it, let's clarify what the Solana CLI is and what you can do with it. It's a comprehensive command-line tool that allows you to perform a wide range of tasks without needing a graphical interface.
Mastering the Solana CLI: Your Ultimate Setup Guide
This article from QuillAudits provides a great overview of the Solana CLI's capabilities. It will help you understand the role this tool plays in the development workflow.
Please read the introduction and the section 'What Exactly is the Solana CLI?'. Pay attention to the bullet points that list its key functionalities.
In essence, the Solana CLI is your command center for:
- Managing Wallets: Creating keypairs, checking balances, and signing transactions.
- Interacting with Networks: Switching between different Solana clusters like
mainnet-beta,devnet,testnet, and a local test validator. - Deploying & Managing Programs: Sending your compiled Rust code (your Solana programs) to the blockchain.
- Querying the Blockchain: Fetching account information, checking transaction statuses, and more.
As an experienced developer, you'll find its utility very familiar—it provides direct, scriptable access to the Solana ecosystem.
Installing the Solana CLI Tool Suite
Now, let's get the CLI installed in your WSL2 environment. The process is straightforward and involves running a single script.
Solana Dev Setup Guide (Part 1: CLI)
This guide by Chris St. John on Medium provides a direct and up-to-date installation command. We will follow this to install the CLI and configure its path.
In your WSL2/Ubuntu terminal, follow the instructions in 'Section 2. Install the Solana CLI', 'Section 2.1 — Add the CLI to our PATH', and 'Section 2.2 — Test it by getting the Solana version'. Use the commands provided for 'Linux and Windows WSL users'.
Let's break down the steps you'll perform from the guide:
-
Run the installation script:
sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)"This downloads and runs the official installer from Anza, the new maintainer of Solana's core code.
-
Update your shell's PATH: Just like we did for Cargo in the last lesson, you need to tell your shell where to find the
solanaexecutable. Add the following line to your~/.bashrcfile (or~/.zshrcif you use Zsh):export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"After adding it, restart your terminal or run
source ~/.bashrcfor the change to take effect. -
Verify the installation:
solana --versionIf the installation was successful, this command will print the installed version of the
solana-cli.
For a visual walkthrough of this process inside WSL2, you can refer back to the video we used in the previous lesson.
Installing All You Need for Solana Development [Solana Basics Tutorial] - Nov 16th '23
The Solandy video you watched before also covers the Solana CLI installation within WSL2. This clip will reinforce the steps you just took.
Watch the sections 'Installing Solana CLI on WSL2 (Linux)' (05:53 - 07:41) and 'Verifying Solana CLI Installation on WSL2' (09:32 - 10:00). You've already performed these steps, so this is just for confirmation.
Configuring the CLI
With the tool installed, we need to configure it. The most important setting is the RPC URL, which tells the CLI which Solana network (or "cluster") to communicate with. This is analogous to setting your API endpoint to a development, staging, or production server in web development.
Solana has several clusters:
mainnet-beta: The live, production network with real assets.devnet: A development network with freely available (and valueless) SOL for testing.testnet: A network for the Solana core developers to test new features.localhost: Your own private network running on your machine (we'll touch on this later).
For our development purposes, we will primarily use Devnet.
The following video and text will guide you through viewing and setting your configuration.
Set Up Your Solana Development Environment | Step-by-Step Beginner Tutorial
This short clip from a tutorial by 'bri' clearly demonstrates how to check your current configuration and switch between different networks like localhost and devnet.
Watch the 'Configuring Solana CLI' section from 02:59 to 04:20. See how solana config get and solana config set --url are used.
Now, let's use the guide from Chris St. John to set our configuration permanently to Devnet and understand what each setting means.
Solana Dev Setup Guide (Part 1: CLI)
This section of the guide not only provides the command to set the Devnet URL but also clearly explains each line of the configuration output, such as the RPC URL, WebSocket URL, and Keypair Path.
Follow the instructions in 'Section 3. Configure CLI for Devnet'. Run the commands to set the network to Devnet and then verify the configuration. Read the explanations for each configuration property.
After following the guide, your CLI will be pointed at Devnet, ready for the next steps.
Creating and Funding a Wallet
To perform any action on the network (like deploying a program), you need a wallet with some SOL to pay for transaction fees. The Solana CLI comes with a built-in "filesystem" wallet.
Important Note: This type of wallet stores your private key in an unencrypted JSON file on your computer. This is perfectly fine for development with valueless Devnet SOL, but you should never use a filesystem wallet for real funds on mainnet.
Let's create a wallet and get some free Devnet SOL via an "airdrop".
Solana Dev Setup Guide (Part 1: CLI)
This guide provides an excellent walkthrough for creating a CLI wallet, setting it as your default, and funding it with an airdrop. It also highlights the critical security considerations.
Read and follow the steps in 'Section 4. Create a Devnet wallet' and 'Section 5. Get free Devnet SOL with an airdrop'. Don't skip the text—it contains important context about keypairs and security. When generating your keypair, you can leave the passphrase empty for development.
To summarize the key commands you will execute:
solana-keygen new --outfile ~/.config/solana/dev-wallet.json: Creates a new wallet file.solana config set --keypair ~/.config/solana/dev-wallet.json: Sets this new wallet as the default for your CLI.solana address: Confirms the public key of your new default wallet.solana airdrop 2: Requests 2 free SOL from the Devnet faucet.solana balance: Checks that your wallet has been funded.
If the airdrop command fails due to rate-limiting, the guide provides a link to a web-based faucet you can use as an alternative.
Test your understanding!
You've just set up your CLI to point to devnet and created a new keypair. If you wanted to test a program on a private, local copy of the blockchain instead, what two solana commands would you need to use? (Hint: one starts the local network, and the other points your CLI to it).
Show answer
solana-test-validator: This command starts a local validator on your machine, creating a privatelocalhostcluster. You would run this in a separate terminal window and leave it running.solana config set --url localhost: This command tells your CLI to send all future transactions and queries to the local validator you just started, instead of the publicdevnet.
Basic Interaction with the Blockchain
Now that you're set up, let's run a few simple, read-only commands to see the CLI in action. These commands query the Devnet cluster for information.
Try running these in your terminal:
solana cluster-version: Confirms you can connect to the cluster and shows its software version.solana epoch-info: Shows information about the current "epoch" (a period of time on the blockchain).solana supply: Displays the total supply of SOL on Devnet.
The Chris St. John guide in sections 4 and 5 walks through these and even a simple transfer transaction if you'd like to try it. This confirms your entire setup—from installation to wallet funding—is working correctly.
Summary and Next Steps
Fantastic work! You have now fully configured the core command-line tooling for Solana development. In this lesson, you have:
- Learned the purpose and capabilities of the Solana CLI.
- Installed the Solana tool suite and added it to your system's PATH.
- Configured the CLI to connect to the Solana Devnet.
- Created a new filesystem wallet, set it as your default, and funded it with test SOL.
You now have all the low-level tools required to build, deploy, and interact with the Solana network from your terminal.
In our next lesson, we will install the Anchor framework. Anchor is a powerful framework that sits on top of the tools we've just installed. It dramatically simplifies and accelerates Solana program development by providing helpful macros, security checks, and client generation, allowing you to focus on your program's logic. Get ready to write some code
Can't find a good explanation? Sign up and we'll make it for you
Sign up