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

> ## Agent Instructions
> This page is part of the Solana developer documentation at https://solana.com/developers/docs. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get the page as Markdown.
> Index of all pages: https://solana.com/llms.txt. Per-section indexes such as https://solana.com/developers/docs/payments/llms.txt are smaller; prefer them when working on one task.
> Coding agents: install the official Solana skill for current APIs and conventions with `npx skills add https://github.com/solana-foundation/solana-dev-skill` (also served at https://solana.com/SKILL.md).
> Code in the cookbook and task pages comes from tested example files. Prefer it over writing API calls from memory.

# Getting Test SOL

> Learn how to get test SOL for development purposes by requesting an airdrop in your source code.

To send transactions while developing locally or on devnet, you'll need SOL.

On a local validator, such as Surfpool or `solana-test-validator`, you can fund
an address by requesting an airdrop, as the examples below do. The public devnet
and testnet endpoints no longer serve airdrops, so on devnet use the
[faucet](https://faucet.solana.com/) instead (see
[more ways to get devnet SOL](/developers/cookbook/development/airdrops-and-faucets)).

<Tabs>
<Tab title="Kit">
<div className="sol-tab-label">Kit</div>

```ts highlight={15-19}
import {
  airdropFactory,
  createSolanaRpc,
  createSolanaRpcSubscriptions,
  generateKeyPairSigner,
  lamports,
} from "@solana/kit";

const rpc = createSolanaRpc("http://localhost:8899");
const rpcSubscriptions = createSolanaRpcSubscriptions("ws://localhost:8900");

const wallet = await generateKeyPairSigner();
const LAMPORTS_PER_SOL = 1_000_000_000n;

await airdropFactory({ rpc, rpcSubscriptions })({
  recipientAddress: wallet.address,
  lamports: lamports(LAMPORTS_PER_SOL), // 1 SOL
  commitment: "confirmed",
});

const { value } = await rpc.getBalance(wallet.address).send();
console.log(`Balance: ${value / LAMPORTS_PER_SOL} SOL`);
```

<div className="sol-run" data-run="cookbook/development/test-sol/airdrop" data-tab="Kit">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Output from a local Surfpool network</span></div>
<div className="sol-run-out">

```text Output
Balance: 1 SOL
```

</div>
</div>

</Tab>
<Tab title="Web3.js v3">
<div className="sol-tab-label">Web3.js v3</div>

```ts highlight={7-10}
import { Connection, Keypair, LAMPORTS_PER_SOL } from "@solana/web3.js";

const connection = new Connection("http://localhost:8899", "confirmed");

const wallet = await Keypair.generate();

const signature = await connection.requestAirdrop(
  wallet.publicKey,
  LAMPORTS_PER_SOL,
);

const { blockhash, lastValidBlockHeight } =
  await connection.getLatestBlockhash();

await connection.confirmTransaction({
  blockhash,
  lastValidBlockHeight,
  signature,
});

const balance = await connection.getBalance(wallet.publicKey);
console.log(`Balance: ${Number(balance) / LAMPORTS_PER_SOL} SOL`);
```

<div className="sol-run" data-run="cookbook/development/test-sol/airdrop" data-tab="Web3.js v3">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Output from a local Surfpool network</span></div>
<div className="sol-run-out">

```text Output
Balance: 1 SOL
```

</div>
</div>

</Tab>
<Tab title="Rust">
<div className="sol-tab-label">Rust</div>

```rust
use anyhow::Result;
use solana_client::nonblocking::rpc_client::RpcClient;
use solana_commitment_config::CommitmentConfig;
use solana_sdk::{native_token::LAMPORTS_PER_SOL, signature::Signer, signer::keypair::Keypair};

#[tokio::main]
async fn main() -> Result<()> {
    let connection = RpcClient::new_with_commitment(
        "http://localhost:8899".to_string(),
        CommitmentConfig::confirmed(),
    );

    let wallet = Keypair::new();

    let airdrop_signature = connection
        .request_airdrop(&wallet.pubkey(), LAMPORTS_PER_SOL)
        .await?;
    loop {
        let confirmed = connection.confirm_transaction(&airdrop_signature).await?;
        if confirmed {
            break;
        }
    }

    let balance = connection.get_balance(&wallet.pubkey()).await?;
    println!("Balance: {} SOL", balance as f64 / LAMPORTS_PER_SOL as f64);

    Ok(())
}
```

<div className="sol-run" data-run="cookbook/development/test-sol/airdrop" data-tab="Rust">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Output from a local Surfpool network</span></div>
<div className="sol-run-out">

```text Output
Balance: 1 SOL
```

</div>
</div>

</Tab>
<Tab title="Python">
<div className="sol-tab-label">Python</div>

```py
import asyncio

from solana.rpc.async_api import AsyncClient
from solders.keypair import Keypair

LAMPORTS_PER_SOL = 1_000_000_000


async def main():
    async with AsyncClient("http://localhost:8899") as client:
        wallet = Keypair()
        airdrop = await client.request_airdrop(wallet.pubkey(), LAMPORTS_PER_SOL)  # 1 SOL
        print("Airdrop Signature:", airdrop.value)


asyncio.run(main())
```

<div className="sol-run" data-run="cookbook/development/test-sol/airdrop" data-tab="Python">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Output from a local Surfpool network</span></div>
<div className="sol-run-out">

```text Output
Airdrop Signature: je9LhSt1xzbjKBro8qpBW9rV2hQRLYCnamohta5YzJoQxfEB3A4jjj7ZzSyJdhuGdrdEcrZUzFCp189iH5ndCqk
```

</div>
</div>

</Tab>
<Tab title="Go">
<div className="sol-tab-label">Go</div>

```go
package main

import (
	"context"
	"fmt"

	"github.com/solana-foundation/solana-go/v2"
	"github.com/solana-foundation/solana-go/v2/rpc"
)

func main() {
	client := rpc.New("http://localhost:8899")

	wallet := solana.NewWallet()
	sig, err := client.RequestAirdrop(
		context.Background(), wallet.PublicKey(), solana.LAMPORTS_PER_SOL, rpc.CommitmentConfirmed, // 1 SOL
	)
	if err != nil {
		panic(err)
	}
	fmt.Println("Airdrop Signature:", sig)
}
```

<div className="sol-run" data-run="cookbook/development/test-sol/airdrop" data-tab="Go">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Output from a local Surfpool network</span></div>
<div className="sol-run-out">

```text Output
Airdrop Signature: 3efa5dts3ugjHYzhqnd82FLUgfG7cUTS81ctUBtEyRkvP9ZFT979sgWsD6D4i3cLvmd4EZ52gwjY2NRhHcJxbdXK
```

</div>
</div>

</Tab>
<Tab title="Web3.js (legacy)">
<div className="sol-tab-label">Web3.js (legacy)</div>

<Warning>
  **`@solana/web3.js` 1.x is no longer actively maintained**

  It receives critical fixes only. Use [Kit](/developers/docs/clients/official/javascript#solana-kit) for new code. To migrate existing code, follow the [Kit upgrade guide](https://www.solanakit.com/docs/upgrade-guide), or the [web3.js v3 migration guide](https://github.com/solana-foundation/solana-web3.js/blob/main/docs/web3js-v1-to-v3-migration.md) to keep the class-based API.

  To run this code, install 1.x with `npm install @solana/web3.js@1`. A plain `npm install @solana/web3.js` installs v3, which this code doesn't run on.
</Warning>

```ts highlight={7-10}
import { Connection, Keypair, LAMPORTS_PER_SOL } from "@solana/web3.js";

const connection = new Connection("http://localhost:8899", "confirmed");

const wallet = Keypair.generate();

const signature = await connection.requestAirdrop(
  wallet.publicKey,
  LAMPORTS_PER_SOL,
);

const { blockhash, lastValidBlockHeight } =
  await connection.getLatestBlockhash();

await connection.confirmTransaction({
  blockhash,
  lastValidBlockHeight,
  signature,
});

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

<div className="sol-run" data-run="cookbook/development/test-sol/airdrop" data-tab="Web3.js (legacy)">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Output from a local Surfpool network</span></div>
<div className="sol-run-out">

```text Output
Balance: 1 SOL
```

</div>
</div>

</Tab>
</Tabs>
