DocsGetting Started

Installation

This section covers the steps to set up your local environment for Solana development.

Install Dependencies

  • Windows users must first install WSL (Windows subsystem for Linux) and then install the dependencies specified in the Linux section below.
  • Linux users should first install the dependencies specified in the Linux section below.
  • Mac users should start with the Rust installation instructions below.

Solana Config

To see your current config:

solana config get

You should see output similar to the following:

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

The RPC URL and Websocket URL specific the Solana cluster the CLI will make requests to. By default this will be mainnet-beta.

You can update the Solana CLI cluster using the following commands:

solana config set --url mainnet-beta
solana config set --url devnet
solana config set --url localhost
solana config set --url testnet

You can also use the following short options:

solana config set -um    # For mainnet-beta
solana config set -ud    # For devnet
solana config set -ul    # For localhost
solana config set -ut    # For testnet

The Keypair Path specifies the location of the default wallet used by the Solana CLI (to pay transaction fees and deploy programs). The default path is ~/.config/solana/id.json. The next step walks through how to generate a keypair at the default location.

Create Wallet

To interact with the Solana network using the Solana CLI, you need a Solana wallet funded with SOL.

To generate a keypair at the default Keypair Path, run the following command:

solana-keygen new

You should see output similar to the following:

Generating a new keypair

For added security, enter a BIP39 passphrase

NOTE! This passphrase improves security of the recovery seed phrae NOT the
keypair file itself, which is stored as insecure plain text

BIP39 Passphrase (empty for none):

Wrote new keypair to /Users/test/.config/solana/id.json
===========================================================================
pubkey: 8dBTPrjnkXyuQK3KDt9wrZBfizEZijmmUQXVHpFbVwGT
===========================================================================
Save this seed phrase and your BIP39 passphrase to recover your new keypair:
cream bleak tortoise ocean nasty game gift forget fancy salon mimic amazing
===========================================================================

Once a keypair is generated, you can get the address (public key) of the keypair with the following command:

solana address

Airdrop SOL

Once you've set up your local wallet, request an airdrop of SOL to fund your wallet. You need SOL to pay for transaction fees and to deploy programs.

Set your cluster to the devnet:

solana config set -ud

Then request an airdrop of devnet SOL:

solana airdrop 2

To check your wallet's SOL balance, run the following command:

solana balance

Run Local Validator

The Solana CLI comes with the test validator built-in. Running a local validator will allow you to deploy and test your programs locally.

In a separate terminal, run the following command to start a local validator:

solana-test-validator

On this page

Edit page