> ## Documentation Index
> Fetch the complete documentation index at: https://www.helius.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# So verwenden Sie requestAirdrop

> Erfahren Sie die Anwendungsfälle von requestAirdrop, Codebeispiele, Anforderungsparameter, Antwortstruktur und Tipps.

Die [`requestAirdrop`](https://www.helius.dev/docs/api-reference/rpc/http/requestairdrop) RPC-Methode ermöglicht es Ihnen, einen Airdrop von SOL (Lamports) auf ein angegebenes Konto zu beantragen. Diese Methode ist **ausschließlich für nicht-Mainnet-Umgebungen** wie Devnet und Testnet gedacht, wo sie als Faucet dient, um Entwicklern kostenlos SOL für das Testen ihrer Anwendungen bereitzustellen.

**Wichtig: Diese Methode funktioniert nicht auf Mainnet Beta.**

## Häufige Anwendungsfälle

* **Finanzierung von Testgeldbörsen:** Erhalt von SOL zur Bezahlung von Transaktionsgebühren und Bereitstellung von Programmen auf Devnet oder Testnet.
* **Automatisiertes Testen:** Scripts können `requestAirdrop` verwenden, um sicherzustellen, dass Testkonten über genügend SOL verfügen, bevor Testsuiten ausgeführt werden.
* **Entwicklung & Experimentieren:** Schneller Erwerb von SOL zur Interaktion mit On-Chain-Programmen während der Entwicklung.

## Anforderungsparameter

1. **`pubkey`** (string, erforderlich): Der öffentliche Schlüssel des Kontos, das die abgeworfenen Lamports erhält, als Base-58-kodierte Zeichenfolge.
2. **`lamports`** (u64, erforderlich): Die Menge der angeforderten Lamports. (1 SOL = 1.000.000.000 Lamports).
3. **`options`** (object, optional): Ein optionales Konfigurationsobjekt, das Folgendes enthalten kann:
   * **`commitment`** (string, optional): Gibt das [Commitment-Level](https://www.helius.dev/blog/solana-commitment-levels) an, auf das beim Bestätigen der Airdrop-Transaktion gewartet werden soll (z.B. `"finalized"`, `"confirmed"`, `"processed"`). Wenn nicht angegeben, wird das Standard-Commitment des Knotens für Airdrops verwendet.

## Antwortstruktur

Das Feld `result` in der JSON-RPC-Antwort ist eine einzelne Zeichenkette, die die Transaktionssignatur des Airdrop in Base-58-kodierter Form darstellt.

**Beispielantwort:**

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

Diese Signatur kann dann mit `getTransaction` oder einem Solana-Explorer verwendet werden, um den Status der Airdrop-Transaktion zu verfolgen.

## Codebeispiele

<CodeGroup>
  ```bash cURL theme={"system"}
  # Request 1 SOL (1,000,000,000 lamports) to a Devnet address
  # Replace <YOUR_WALLET_ADDRESS> with an actual base-58 public key
  # Ensure you are targeting a Devnet RPC URL
  curl -X POST -H "Content-Type: application/json" -d \
    '{
      "jsonrpc": "2.0",
      "id": 1,
      "method": "requestAirdrop",
      "params": [
        "<YOUR_WALLET_ADDRESS>",
        1000000000
      ]
    }' \
    https://devnet.helius-rpc.com/?api-key=<api-key> 

  # Request 0.5 SOL with "confirmed" commitment
  curl -X POST -H "Content-Type: application/json" -d \
    '{
      "jsonrpc": "2.0",
      "id": 1,
      "method": "requestAirdrop",
      "params": [
        "<YOUR_WALLET_ADDRESS>",
        500000000,
        {
          "commitment": "confirmed"
        }
      ]
    }' \
    https://devnet.helius-rpc.com/?api-key=<api-key>
  ```

  ```javascript JavaScript (using @solana/web3.js) theme={"system"}
  const { Connection, PublicKey, LAMPORTS_PER_SOL } = require('@solana/web3.js');

  async function getAirdrop(walletAddress) {
    // Connect to Devnet
    const connection = new Connection('https://devnet.helius-rpc.com/?api-key=<api-key>', 'confirmed');
    const publicKey = new PublicKey(walletAddress);

    try {
      console.log(`Requesting airdrop of 1 SOL to ${walletAddress} on Devnet...`);
      
      // Request an airdrop of 1 SOL
      const airdropSignature = await connection.requestAirdrop(
        publicKey,
        LAMPORTS_PER_SOL // 1 SOL
      );

      console.log(`Airdrop requested. Transaction signature: ${airdropSignature}`);

      // Confirm the transaction
      // Note: The `confirmTransaction` method in web3.js has evolved.
      // For newer versions, you might use `connection.confirmTransaction({ signature: airdropSignature, blockhash: latestBlockhash.blockhash, lastValidBlockHeight: latestBlockhash.lastValidBlockHeight }, 'confirmed');`
      // For simplicity, we'll log the signature and you can check on an explorer.
      // Or, more robustly, you can poll getSignatureStatuses.

      await connection.confirmTransaction(airdropSignature);
      console.log(`Airdrop successful for ${walletAddress}!`);

      const balance = await connection.getBalance(publicKey);
      console.log(`Current balance for ${walletAddress}: ${balance / LAMPORTS_PER_SOL} SOL`);

    } catch (error) {
      console.error(`Error requesting airdrop for ${walletAddress}:`, error);
    }
  }

  // Replace with a Devnet wallet address you control
  const myDevnetWallet = 'REPLACE_WITH_YOUR_DEVNET_WALLET_ADDRESS'; 
  // Example: const myDevnetWallet = new Keypair().publicKey.toBase58(); // For a new temporary wallet

  if (myDevnetWallet === 'REPLACE_WITH_YOUR_DEVNET_WALLET_ADDRESS') {
    console.warn("Please replace 'REPLACE_WITH_YOUR_DEVNET_WALLET_ADDRESS' with an actual Devnet wallet address to run the example.");
  } else {
    // getAirdrop(myDevnetWallet);
    console.log("Uncomment the line above and replace the placeholder to run the airdrop example.");
  }
  ```
</CodeGroup>

## Entwickler-Tipps

* **Netzwerkspezifisch:** Diese Methode funktioniert nur in Testnetzwerken (Devnet, Testnet), die über einen aktivierten Faucet verfügen. Sie schlägt auf Mainnet Beta fehl.
* **Ratenbegrenzung:** Airdrop-Faucets sind oft rate-limitiert, um Missbrauch zu verhindern. Wenn Sie in kurzer Zeit zu viele Anfragen stellen, können Sie Fehler erhalten.
* **Betragsbegrenzungen:** Es kann Begrenzungen geben, wie viel SOL Sie pro Airdrop oder pro Zeitperiode anfordern können.
* **Bestätigung:** Nachdem `requestAirdrop` eine Signatur zurückgibt, muss die Transaktion noch vom Netzwerk verarbeitet und bestätigt werden. Sie können `confirmTransaction` (von `@solana/web3.js`) verwenden oder `getSignatureStatuses` abfragen, um auf die Bestätigung zu warten.

Dieser Leitfaden erklärt, wie Sie `requestAirdrop` verwenden, um Ihre Testkonten auf Solanas Entwicklungsnetzwerken zu finanzieren.

## Verwandte Methoden

<CardGroup cols={2}>
  <Card title="getBalance" href="/docs/de/api-reference/rpc/http/getbalance">
    Überprüfen Sie das SOL-Guthaben nach Erhalt eines Airdrop
  </Card>

  <Card title="getSignatureStatuses" href="/docs/de/api-reference/rpc/http/getsignaturestatuses">
    Abfrage des Transaktionsstatus zur Bestätigung des Airdrop
  </Card>
</CardGroup>
