requestAirdrop
Requests a faucet transaction that transfers lamports to the supplied Pubkey.
Request
Send a JSON-RPC 2.0 POST request with method: "requestAirdrop". The params array takes a base-58 encoded public key, the number of lamports to airdrop, and an optional configuration object.
curl · JSON-RPCjson
{ "jsonrpc": "2.0", "id": 1, "method": "requestAirdrop", "params": [ "83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri", 1000000000, { "commitment": "finalized" } ]}@solana/kit
kit.tsts
import { address, createSolanaRpc, lamports } from "@solana/kit";import { LAMPORTS_PER_SOL } from "@solana/web3.js"; const rpc_url = "https://rpc.openinfra.sh";const rpc = createSolanaRpc(rpc_url); let receiver = address("4kg8oh3jdNtn7j2wcS7TrUua31AgbLzDVkBZgTAe44aF");let airdropAmt = lamports(BigInt(1 * LAMPORTS_PER_SOL)); let signature = await rpc.requestAirdrop(receiver, airdropAmt).send(); console.log(signature);@solana/web3.js
web3.tsts
import { Connection, LAMPORTS_PER_SOL, PublicKey, clusterApiUrl} from "@solana/web3.js"; const connection = new Connection("https://rpc.openinfra.sh", "confirmed"); let receiver = new PublicKey("4kg8oh3jdNtn7j2wcS7TrUua31AgbLzDVkBZgTAe44aF");let airdropAmt = 1 * LAMPORTS_PER_SOL; let sig = await connection.requestAirdrop(receiver, airdropAmt); console.log(sig);Rust
main.rsrs
use anyhow::Result;use solana_client::nonblocking::rpc_client::RpcClient;use solana_commitment_config::CommitmentConfig;use solana_sdk::{native_token::LAMPORTS_PER_SOL, pubkey}; #[tokio::main]async fn main() -> Result<()> { let client = RpcClient::new_with_commitment( String::from("https://rpc.openinfra.sh"), CommitmentConfig::confirmed(), ); let receiver = pubkey!("4kg8oh3jdNtn7j2wcS7TrUua31AgbLzDVkBZgTAe44aF"); let lamports = 1 * LAMPORTS_PER_SOL; let transaction_signature = client.request_airdrop(&receiver, lamports).await?; loop { if client.confirm_transaction(&transaction_signature).await? { break; } } println!("{}", transaction_signature); Ok(())}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| pubkey | string | Yes | Pubkey of the account to receive lamports, as a base-58 encoded string. |
| lamports | u64 | Yes | Amount of lamports to airdrop. |
| config | object | No | Optional configuration object. See fields below. |
| config.commitment | string | No | Desired finality level for the faucet transaction. Accepted values: processed, confirmed, finalized (default). |
| config.recentBlockhash | string | No | Use this recent blockhash for the faucet transaction instead of the node's current confirmed blockhash. |
commitment values
| Value | Description |
|---|---|
| processed | Return data from the highest slot this node has processed on the fork it currently considers best. This is the newest view, but it can still change if the cluster switches forks. |
| confirmed | Return data from the highest slot that at least two-thirds of active stake has directly voted to confirm. More stable than processed, but a weaker guarantee than finalized. |
| finalized | Return data from the highest slot that the cluster recognizes as finalized. The slot has reached maximum vote lockout in validators' vote towers and is recognized by at least two-thirds of active stake. This is the strongest commitment level. |
recentBlockhash example
{ "recentBlockhash": "EkSnNWid2cvwEVnVx9aBqawnmiCNiDgp3gUdkDPTKN1N" }Response
response.jsonjson
{ "jsonrpc": "2.0", "result": "4cdd1oX7cfVALfr26tP52BZ6cSzrgnNGtYD7BFhm6FFeZV5sPTnRvg6NRn8yC6DbEikXcrNChBM5vVJnTgKhGhVu", "id": 1}The result is a transaction signature string, as a base-58 encoded value. You can use this signature to confirm the airdrop landed on chain.
| Field | Type | Description |
|---|---|---|
| result | string | Transaction signature of the airdrop, as a base-58 encoded string. |