requestAirdrop RPC method allows you to request an airdrop of SOL (lamports) to a specified account. This method is exclusively for non-mainnet environments like Devnet and Testnet, where it serves as a faucet to provide developers with free SOL for testing their applications.
Important: This method will not work on Mainnet Beta.
Common Use Cases
- Funding Test Wallets: Obtaining SOL to pay for transaction fees and deploy programs on Devnet or Testnet.
- Automated Testing: Scripts can use
requestAirdropto ensure test accounts have sufficient SOL before running test suites. - Development & Experimentation: Quickly acquiring SOL to interact with on-chain programs during development.
Request Parameters
pubkey(string, required): The public key of the account that will receive the airdropped lamports, provided as a base-58 encoded string.lamports(u64, required): The amount of lamports to request. (1 SOL = 1,000,000,000 lamports).options(object, optional): An optional configuration object that can include:commitment(string, optional): Specifies the commitment level to wait for when confirming the airdrop transaction (e.g.,"finalized","confirmed","processed"). If omitted, the node’s default commitment for airdrops is used.
Response Structure
Theresult field in the JSON-RPC response is a single string representing the transaction signature of the airdrop, base-58 encoded.
Example Response:
getTransaction or a Solana explorer to track the status of the airdrop transaction.
Code Examples
Developer Tips
- Network Specific: This method is only functional on test networks (Devnet, Testnet) that have a faucet enabled. It will fail on Mainnet Beta.
- Rate Limiting: Airdrop faucets are often rate-limited to prevent abuse. If you make too many requests in a short period, you might receive errors.
- Amount Limits: There might be limits on the amount of SOL you can request per airdrop or per time period.
- Confirmation: After
requestAirdropreturns a signature, the transaction still needs to be processed and confirmed by the network. You can useconfirmTransaction(from@solana/web3.js) or pollgetSignatureStatusesto wait for confirmation.
requestAirdrop to fund your test accounts on Solana’s development networks.