# requestAirdrop

The `requestAirdrop` RPC method in **CoinVera** is used to request a small amount of **SOL (in lamports)** to a specified account on **test networks** like **Devnet** or **Testnet**. It acts as a faucet to provide developers with free SOL for testing and experimentation.

> ⚠️ **Important**: This method does **not work on Mainnet Beta**. It is restricted to test environments with faucet functionality.

***

#### ✅ Common Use Cases

* **Funding Test Wallets**\
  Acquire SOL for paying transaction fees and deploying programs on Devnet/Testnet.
* **Automated Testing Pipelines**\
  Ensure test accounts are pre-funded before running integration or e2e tests.
* **Developer Experimentation**\
  Quickly receive SOL to experiment with smart contracts or token transfers in a safe sandbox environment.

***

#### 🧾 Request Parameters

```ts
[
  pubkey: string,             // Required – Base-58 public key of the recipient
  lamports: number,           // Required – Amount to airdrop (1 SOL = 1_000_000_000 lamports)
  options?: {
    commitment?: string       // Optional – "processed", "confirmed", or "finalized"
  }
]
```

* **pubkey** *(required)*:\
  The address to receive the airdrop, base-58 encoded.
* **lamports** *(required)*:\
  Amount of SOL to request (in lamports).\
  Example: 1 SOL = `1000000000` lamports.
* **commitment** *(optional)*:\
  Commitment level to use when confirming the airdrop transaction.

***

#### 📦 Response Structure

```json
{
  "result": "3oZMg7M...AirdropTxSignature"
}
```

* **result**: A base-58 encoded transaction signature for the airdrop.\
  You can use this with `getSignatureStatuses` or `confirmTransaction` to confirm completion.

***

#### 🧪 Example

**Airdrop 1 SOL to a Devnet Account**

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "requestAirdrop",
  "params": [
    "4H6B3d4xNoXyRzk9m1eM2PK2shTyzj2UTh8uUreVfEnz",
    1000000000,
    {
      "commitment": "confirmed"
    }
  ]
}
```

***

**Code Examples**

{% tabs %}
{% tab title="Nodejs" %}

```javascript
const fetch = require('node-fetch');

async function requestAirdrop(rpcUrl) {
  try {
    const response = await fetch(rpcUrl, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        jsonrpc: '2.0',
        id: 1,
        method: 'requestAirdrop',
        "params": [
            "4UJuvGZ7Ge8H3je63Nsb9ZRNVBAd3CG2ajibnRaVSbw5",
            500000000,
            {
              "commitment": "confirmed"
            }
          ]
      }),
    });

    const data = await response.json();
    
    // Print the exact full response
    console.log('Full RPC Response:');
    console.log(JSON.stringify(data, null, 2));
    
    return data;
  } catch (error) {
    console.error('Error getting health:', error.message);
    return null;
  }
}

// Example usage
const RPC_URL = 'https://devnet-rpc.coinvera.io/?x-api-key=your-coinvera-x-api-key';

requestAirdrop(RPC_URL);
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

def request_airdrop(rpc_url):
    try:
        response = requests.post(
            rpc_url,
            headers={
                'Content-Type': 'application/json',
            },
            json={
                'jsonrpc': '2.0',
                'id': 1,
                'method': 'requestAirdrop',
                'params': [
                    '4UJuvGZ7Ge8H3je63Nsb9ZRNVBAd3CG2ajibnRaVSbw5',
                    500000000,
                    {
                        'commitment': 'confirmed'
                    }
                ]
            }
        )
        
        data = response.json()
        
        # Print the exact full response
        print('Full RPC Response:')
        print(json.dumps(data, indent=2))
        
        return data
        
    except Exception as error:
        print(f'Error getting health: {error}')
        return None

# Example usage
RPC_URL = 'https://devnet-rpc.coinvera.io/?x-api-key=your-coinvera-x-api-key'
request_airdrop(RPC_URL)
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "jsonrpc": "2.0",
  "result": "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW",
  "id": 1
}
```

***

#### 💡 Developer Tips

* **Testnet Only**\
  This method is only supported on **Devnet** or **Testnet**. It will **fail** if used on Mainnet.
* **Rate Limits & Quotas**\
  Faucet endpoints often restrict how often or how much you can airdrop. If you're testing frequently, space out your requests.
* **Confirmation Handling**\
  The method returns a transaction signature—but confirmation is **not guaranteed** immediately. Use:
  * `getSignatureStatuses`
  * `confirmTransaction` (from `@solana/web3.js`)
  * `getTransaction` for full details
* **Useful for Continuous Integration**\
  Include airdrop requests in test scripts to automate funding of ephemeral test accounts.

***

The `requestAirdrop` method is an essential developer tool when building and testing on Solana's Devnet or Testnet using **CoinVera**. It provides a frictionless way to acquire SOL for experimentation, testing, and rapid prototyping.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.coinvera.io/integration/solana/rpc/requestairdrop.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
