> ## 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.

# requestAirdrop 사용 방법

> requestAirdrop 사용 사례, 코드 예제, 요청 매개변수, 응답 구조 및 팁을 학습합니다.

[`requestAirdrop`](https://www.helius.dev/docs/api-reference/rpc/http/requestairdrop) RPC 메서드는 특정 계정에 SOL(람포트)을 에어드롭 요청할 수 있게 해줍니다. 이 메서드는 Devnet 및 Testnet과 같은 **비메인넷 환경 전용**으로, 개발자가 애플리케이션을 테스트하기 위해 무료 SOL을 제공하는 수도꼭지 역할을 합니다.

**중요: 이 메서드는 Mainnet Beta에서 작동하지 않습니다.**

## 일반적인 사용 사례

* **테스트 지갑 자금 조달:** Devnet 또는 Testnet에서 거래 수수료를 지불하고 프로그램을 배포하기 위한 SOL 획득.
* **자동화된 테스트:** 테스트 스위트를 실행하기 전에 테스트 계정에 충분한 SOL이 있는지 확인하는 스크립트에서 `requestAirdrop`를 사용할 수 있습니다.
* **개발 및 실험:** 개발 중 온체인 프로그램과 상호작용하기 위해 빠르게 SOL을 획득.

## 요청 매개변수

1. **`pubkey`** (문자열, 필수): 베이스-58로 인코딩된 문자열로 제공된 에어드롭을 받을 계정의 공개 키.
2. **`lamports`** (u64, 필수): 요청할 람포트의 양. (1 SOL = 1,000,000,000 람포트).
3. **`options`** (객체, 선택적): 포함할 수 있는 선택적 구성 객체:
   * **`commitment`** (문자열, 선택적): 에어드롭 거래를 확인할 때 기다릴 [커밋 수준](https://www.helius.dev/blog/solana-commitment-levels) 지정 (예: `"finalized"`, `"confirmed"`, `"processed"`). 생략하면 노드의 기본 에어드롭 커밋이 사용됩니다.

## 응답 구조

JSON-RPC 응답의 `result` 필드는 에어드롭 트랜잭션의 서명, 베이스-58로 인코딩된 단일 문자열을 나타냅니다.

**예시 응답:**

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

이 서명은 이후 `getTransaction` 또는 Solana 탐색기와 함께 사용하여 에어드롭 거래 상태를 추적하는 데 사용할 수 있습니다.

## 코드 예제

<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>

## 개발자 팁

* **네트워크 특정:** 이 메서드는 수도꼭지가 활성화된 테스트 네트워크(Devnet, Testnet)에서만 작동합니다. Mainnet Beta에서는 실패합니다.
* **속도 제한:** 에어드롭 수도꼭지는 오용을 방지하기 위해 종종 속도 제한이 있습니다. 짧은 시간에 너무 많은 요청을 하면 오류가 발생할 수 있습니다.
* **금액 제한:** 에어드롭당 또는 일정 시간당 요청할 수 있는 SOL의 양에 제한이 있을 수 있습니다.
* **확인:** `requestAirdrop`가 서명을 반환한 후에도 네트워크에서 거래를 처리하고 확인해야 합니다. `confirmTransaction` (`@solana/web3.js`에서) 또는 `getSignatureStatuses`를 반복 조회하여 확인을 기다릴 수 있습니다.

이 가이드는 Solana의 개발 네트워크에서 테스트 계정에 자금을 제공하기 위해 `requestAirdrop` 사용하는 방법을 설명합니다.

## 관련 메서드

<CardGroup cols={2}>
  <Card title="getBalance" href="/docs/ko/api-reference/rpc/http/getbalance">
    에어드롭을 받은 후 SOL 잔액 확인
  </Card>

  <Card title="getSignatureStatuses" href="/docs/ko/api-reference/rpc/http/getsignaturestatuses">
    에어드롭을 확인하기 위해 거래 상태를 조회
  </Card>
</CardGroup>
