QuickNode Raises $60M Series B!
Read the Letter from our CEO.

A Complete Guide to Airdropping Test SOL on Solana

December 16, 2022

Overview

Building on Solana is a lot of fun. To test your code before production, it is generally best practice to run on Localhost, Devnet, or Testnet. These are safe environments for you to test your code without the consequences of losing real tokens. But to operate in any of these environments, you will need SOL tokens on that cluster. In this guide, we will cover three ways to airdrop test SOL to your wallet:

  • Using Solana's Command Line Interface (Solana CLI)
  • Using Solana's JavaScript API
  • Using QuickNode's Multi-chain Faucet

What You Will Need

Clusters

Before jumping into our airdrops, let's do a quick recap on Solana's clusters, as we will need to specify a specific cluster when requesting an airdrop. "A Solana cluster is a set of validators working together to serve client transactions and maintain the integrity of the ledger. Many clusters may coexist." (Source: docs.solana.com/cluster/overview). In fact, Solana maintains three clusters that each serve different purposes:

  • Mainnet Beta: production, permissionless environment where real tokens are used (note: we cannot request SOL airdrops on the Mainnet Beta cluster)
  • Devnet: a playground for application developers testing Solana applications (tokens on Devnet are not real and have no financial value). Devnet usually runs the same software release as Mainnet Beta
  • Testnet: an environment where Solana core contributors and validators stress test new updates and features, with a focus on testing network performance (tokens on Testnet are not real and have no financial value)
In addition to the three clusters outlined above, Solana CLI (we will cover this more in just a minute) allows you to launch a local test validator to run a complete blockchain cluster on your machine. A local cluster will enable you to deploy and test programs fast, and like Devnet and Testnet, Localhost tokens are not real. We will cover local clusters in a separate guide--if you want more information, check out Solana's Local Development Quickstart Guide.

To perform transactions on any given cluster, you will need SOL on that cluster to cover transaction fees and rent. Let's drop you some tokens!

Method 1 - Airdropping Test SOL through the Solana CLI

Our first method is to request an airdrop using Solana CLI. If you do not already have it installed, follow the instructions for your operating environment at docs.solana.com/cli/install-solana-cli-tools. To make sure your installation was successful, open a new terminal and type:

method 1 airdropping test sol through the solana cli

Copy
solana --version
You should see something like this:


You're ready to go! All you need to do is get your Wallet address handy--you can copy it directly from Phantom:



Request the airdrop of 1 SOL by calling the airdrop sub-command, passing in the amount of SOL to be airdropped and the destination wallet address:

method 1 airdropping test sol through the solana cli

Copy
solana airdrop 1 YOUR_PHANTOM_WALLET_ADDRESS -u devnet # for Devnet
# or 
solana airdrop 1 YOUR_PHANTOM_WALLET_ADDRESS -u testnet # for Testnet
# or 
solana airdrop 1 YOUR_PHANTOM_WALLET_ADDRESS -u localhost # for Localhost (local validator must be running)
# or 
solana airdrop 1 YOUR_PHANTOM_WALLET_ADDRESS -u https://example.solana.quiknode.pro/000000/

Note: at present, airdrops on devnet are limited to 2 sol per request and testnet to 1 sol per requestion--both may be subject to daily limits
You should see a transaction propagate and a signature confirmation like this:



You can check your balance in Phantom by clicking the icon in the top left corner, selecting "Developer Settings," then "Change Network." Then select the same network you requested for your drop (e.g., "Devnet"):




Good job! If you get stuck with Solana CLI, try running solana airdrop -h for a menu of help options.

Method 2 - Airdropping Test SOL with Solana's JavaScript API

Solana Web3 allows you to make RPC calls using JavaScript, cURL, or Python. Solana Web3 includes a method, requestAirdrop, to drop development tokens on applicable clusters. We will cover a JavaScript call here--if you want to follow along in Python or cURL, check out our Solana Documentation here.

Create a new project directory and file, airdrop.js, in your terminal with the following:

method 2 airdropping test sol with solana s javascript api

Copy
mkdir airdrop_sol
cd airdrop_sol
echo > airdrop.js

Install Solana Web3 dependencies:

method 2 airdropping test sol with solana s javascript api

Copy
yarn init -y
yarn add @solana/web3.js

or

method 2 airdropping test sol with solana s javascript api

Copy
npm init -y
npm install --save @solana/web3.js

Open airdrop.js in a code editor of choice, and on line 1, require @solana/web3.js and store it in a constant, SOLANA. On line 2, destructure SOLANA to get a few necessary classes, methods, and constants.

method 2 airdropping test sol with solana s javascript api

Copy
const SOLANA = require('@solana/web3.js');
const { Connection, PublicKey, LAMPORTS_PER_SOL, clusterApiUrl } = SOLANA;

On line 4, create a new variable SOLANA_CONNECTION to establish a connection to the Devnet cluster. On line 5, paste your wallet address. On line 6, set the AIRDROP_AMOUNT equal to 1 SOL in lamports (using the LAMPORTS_PER_SOL constant):

method 2 airdropping test sol with solana s javascript api

Copy
const SOLANA_CONNECTION = new Connection(clusterApiUrl('devnet'));
const WALLET_ADDRESS = 'YOUR_PHANTOM_WALLET_ADDRESS'; //👈 Replace with your wallet address
const AIRDROP_AMOUNT = 1 * LAMPORTS_PER_SOL; // 1 SOL 

On line 7, paste this airdrop script:

method 2 airdropping test sol with solana s javascript api

Copy
(async () => {
    console.log(`Requesting airdrop for ${WALLET_ADDRESS}`)
    // 1 - Request Airdrop
    const signature = await SOLANA_CONNECTION.requestAirdrop(
        new PublicKey(WALLET_ADDRESS),
        AIRDROP_AMOUNT
    );
    // 2 - Fetch the latest blockhash
    const { blockhash, lastValidBlockHeight } = await SOLANA_CONNECTION.getLatestBlockhash();
    // 3 - Confirm transaction success
    await SOLANA_CONNECTION.confirmTransaction({
        blockhash,
        lastValidBlockHeight,
        signature
    },'finalized');
    // 4 - Log results
    console.log(`Tx Complete: https://explorer.solana.com/tx/${signature}?cluster=devnet`)
})();

Let's walk through this script. Notice we must use an async wrapper for this code as we will be waiting for several responses from the Solana cluster.

  1. Use the Solana Web3 requestAirdrop method to drop our specified amount of lamports to our defined WALLET_ADDRESS. This call will return a transaction ID that we define as signature.
  2. Fetch the latest blockhash information from the cluster using the getLatestBlockhash method. This is necessary to confirm that our transaction has succeeded (and not timed out).
  3. Confirm our transaction success by passing our outputs from the previous two queries into confirmTransaction. Additionally, we will specify that we want to wait until the transaction status is finalized, meaning the transaction's block has been committed.
  4. We log a link to the transaction on Solana explorer.
Here's our script in its entirety:

method 2 airdropping test sol with solana s javascript api

Copy
const SOLANA = require('@solana/web3.js');
const { Connection, PublicKey, LAMPORTS_PER_SOL, clusterApiUrl } = SOLANA;
const SOLANA_CONNECTION = new Connection(clusterApiUrl('devnet'));
const WALLET_ADDRESS = 'YOUR_PHANTOM_WALLET_ADDRESS'; //👈 Replace with your wallet address
const AIRDROP_AMOUNT = 1 * LAMPORTS_PER_SOL; // 1 SOL 

(async () => {
    console.log(`Requesting airdrop for ${WALLET_ADDRESS}`)
    const signature = await SOLANA_CONNECTION.requestAirdrop(
        new PublicKey(WALLET_ADDRESS),
        AIRDROP_AMOUNT
    );
    const { blockhash, lastValidBlockHeight } = await SOLANA_CONNECTION.getLatestBlockhash();
    await SOLANA_CONNECTION.confirmTransaction({
        blockhash,
        lastValidBlockHeight,
        signature
    },'finalized');
    console.log(`Tx Complete: https://explorer.solana.com/tx/${signature}?cluster=devnet`)
})();

From your terminal, run your script:

method 2 airdropping test sol with solana s javascript api

Copy
node airdrop

You should see something like this:



Great job!

Method 3 - Airdropping Test SOL via the QuickNode Faucet

If you do not feel like running your own script, no worries! QuickNode recently launched an easy-to-use multi-chain faucet. All you need to do is head over to QuickNode Multi-chain Faucet and connect your wallet (or paste your wallet address). Make sure Solana Devnet or Testnet is selected:



You can choose to tweet for a larger airdrop or just hit "No thanks, just send me 1 SOL." That's it! Wait a few moments for your transaction to confirm, and you now have a no-code solution to get some dev/test SOL in your wallet!

Wrap Up

1, 2, 3 ways to get SOL for testing your dApps on Solana's Devnet and Testnet. So what are you waiting for? Time to get building! Looking for some ideas for what to build with all that SOL? Check out a few of our guides to give you some inspiration:


Show us what you are building on Twitter or Discord. We'd love to see what you are up to!

We ❤️ Feedback

If you have any feedback on this guide, let us know!

Related articles 41

Solana NFT Metadata Deep Dive
Published: Dec 16, 2022
Updated: Dec 16, 2022

Even in the 2022 bear market, Solana NFTs are showing no signs of slowing down. If you are building with Solana NFTs, understanding your NFTs' metadata will make it easier for you to deploy...

Continue reading
How to Transfer SPL Tokens on Solana
Published: Sep 23, 2022
Updated: Sep 23, 2022

Sending Solana Program Library (SPL) Tokens is a critical mechanism for Solana development. Whether you are airdropping whitelist tokens to your community, bulk sending NFTs to another wallet,...

Continue reading
Como crear un NFT en SOLANA
Published: Dec 27, 2021
Updated: Sep 23, 2022

¡Hola querido lector! Bienvenidos a una nueva guía de Solana.Solana es una blockchain que promete mucho a la hora de intentar resolver los problemas de escalabilidad que...

Continue reading
How to Mint an NFT on Solana
Published: Aug 27, 2021
Updated: Sep 23, 2022

Updated at: April 10, 2022Welcome to another QuickNode guide on Solana - the up-and-coming blockchain that seeks to solve the scalability issues of Ethereum. We will be walking through...

Continue reading
How to Send Bulk Transactions on Solana
Published: Aug 31, 2022
Updated: Oct 3, 2022

Are you running a batch process that has many transactions? Perhaps an airdrop to your community's NFT holders or a token distribution to early users of your dApp. Solana transaction...

Continue reading
How to Burn SPL Tokens on Solana
Published: Jan 13, 2023
Updated: Jan 13, 2023

🔥🔥🔥Building a deflationary token protocol? Want to destroy a rugged NFT? Just want to have some fun with your community? The Solana SPL Token Program's Burn feature is what...

Continue reading
How to Get Transaction Logs on Solana
Published: Jun 24, 2022
Updated: Oct 27, 2022

Ever need to pull all the transactions associated with a Wallet? Want to see all of the mint transactions associated with a Candy Machine? Or maybe see transaction history of an NFT? Solana's...

Continue reading
How to Use Priority Fees on Solana
Published: Jan 13, 2023
Updated: Jan 17, 2023

Are you looking to get your transactions confirmed as quickly as possible on Solana? This guide will show you how to use priority fees to bid for priority in the leader's queue and confirm...

Continue reading
Solana Fundamentals Reference Guide
Published: Oct 27, 2022
Updated: Oct 27, 2022

The Solana blockchain is a powerful tool, delivering thousands of transactions per second with almost no-cost transaction fees. If you are new to Web3 or have developed on EVM-based...

Continue reading