0%
Overview page background
HomeOverviewsSolana
Everything You Need to Know About Solana's Devnet

Everything You Need to Know About Solana's Devnet

Alchemy headshot

Written by Alchemy

Brady Werkheiser headshot

Reviewed by Brady Werkheiser

Published on July 21, 20224 min read

Solana’s fast transaction speeds, low transaction costs, and developer-friendly environment make it an excellent chain for both dApp developers and users. If you're looking to start building on Solana, this article explains Solana's Devnet, an essential developer resource for testing smart contracts on a test network that mimics Solana's mainnet.

A cluster is a set of nodes which are responsible for evaluating the validity of incoming transactions to be added to the blockchain. 

In each cluster one node is designated the ‘leader’ (the leader changes roughly every two days), which suggests which transactions should be added to the blockchain’s ledger and signs the suggested transactions with their signature. The other nodes within the cluster are ‘validators’, who double check whether the transactions are valid.

The Solana Devnet is an environment that replicates the actual Solana network (i.e. Mainnet) environment, but uses test SOL tokens to complete transactions so web3 developers don’t need to spend actual money to test their smart contracts.

The Solana Devnet is a safe playground for developers, users, and validators to test applications at no risk.

To prevent network congestion from malicious actors while keeping the network free to use, the Solana Devnet uses a different token than mainnet. 

Devnet tokens can be acquired either through the Solana Devnet faucet or from the following airdrop command you can enter in the Command Line Interface (CLI).

Copied
solana airdrop 2 --url https://api.devnet.solana.com

The Solana Devnet explorer allows web3 developers to search for any block, transaction, program, or token on the devnet. This tool helps developers get information about their transactions, debug transactions that aren’t working properly, and explore program details.

The difference between Solana’s Devnet and the Solana Testnet is that the testnet is a network meant to be used by Solana’s core developer team to test planned updates to the main network while Devnet is a testing environment for the general public to use.

Before connecting to Solana's Devnet, it's important to make sure you install the essential Solana developer tools in your local environment. If you're starting from scratch, you can install the basic tools using the following instructions.

First, will need the Solana Tool Suite to connect to the Devnet. How you install the tool suite will depend on whether or not you're running a MacOS, Linux, or Windows operating system. Here are instructions for each development environment.

If your operating system is MacOS or Linux, open your favorite terminal application and copy-paste the below command.

Copied
sh -c "$(curl -sSfL https://release.solana.com/v1.10.31/install)"

The version number can be replaced with any version which you wish to install

If Windows is your operating system, copy paste the below into Command Prompt instead.

Copied
curl https://release.solana.com/v1.10.31/solana-install-init-x86_64-pc-windows-msvc.exe --output C:\solana-install-tmp\solana-install-init.exe --create-dirs

Run this command to install the Tool Suite:

Copied
C:\solana-install-tmp\solana-install-init.exe v1.10.31

Afterwards for all operating systems, run this to double check you have the desired version of Solana.

Copied
solana --version

Lastly, execute this command to connect to the Devnet cluster, and you will have connected to Devnet.

Copied
solana config set --url https://api.devnet.solana.com

In this tutorial we’re going to deploy the HelloWorld program that the Solana team developed. It creates a count for the account it is called on which represents the number of times that this program has been called on this account historically.

For example, the first execution will increase the count to 1 but return a count of 0. The second will return a count of 1 and increase it to 2. 

Because we have already installed the Solana Tool Suite, we just need to install the following dependencies:

  1. NodeJS

  2. Rust

  3. Git

Once the dependencies are installed, we'll clone the HelloWorld repo and follow the required steps to deploy it on Solana's Devnet.

To install NodeJS (you’ll need v14 or higher for this tutorial) - select the installer that matches your operating system.

After following the steps shown from running the installer NodeJS will automatically execute the node commands below in your terminal.

To install Rust, run this command if your operating system is MacOS, Linux, or other Unix-like operating systems, and your command line is ready.

Copied
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

On Windows, download and install rustup-init.exe.

To install Git on Windows, select an installer to match your Windows version and follow the instructions.

To install Git on MacOS and Linux, first install Homebrew with the following command in your terminal of choice. 

Copied
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Then run the following command in the terminal to install Git with Homebrew.

Copied
$ brew install git

With the dependencies installed, next, clone the HelloWorld repository in your environment.

Copied
git clone https://github.com/solana-labs/example-helloworldcd example-helloworld

Double-check if you are connected to the Devnet cluster by running the following command. 

Copied
solana config get

If you are not connected to the Devnet cluster, connect to the Devnet using this command:

Copied
solana config set --url https://api.devnet.solana.com

Now, generate a keypair, which consists of a public key (your wallet address) and a private seed phrase. This keypair allows you to create an account on-chain and interact with Solana programs.

Copied
solana-keygen new --force

You’re going to need Devnet SOL tokens in order to run our program on the Devnet. You can request tokens through the following command. 

Copied
solana airdrop 2 --url https://api.devnet.solana.com

Now, build the program and deploy it to Devnet.

Copied
npm run build:program-rust

At the bottom of the output that the console provides from building the program should be the command for deploying the program.

If you can’t find it, copy paste the command below to deploy the program to Solana’s Devnet.

Copied
solana program deploy dist/program/helloworld.so

Using the Solana Devnet, web3 developers can build dApps on one of the highest performance layer 1 blockchains in the world. To start building, signup for access to Alchemy's Solana API.

Overview cards background graphic
Desktop section background image

Build blockchain magic

Alchemy combines the most powerful web3 developer products and tools with resources, community and legendary support.

Get your API key