Getting Test SOL
When you're working locally, you need some SOL in order to send transactions. In non-mainnet environments you can receive SOL by airdropping it to your address:
import {address,lamports,airdropFactory,createSolanaClient,LAMPORTS_PER_SOL,} from "gill";const { rpc, rpcSubscriptions, sendAndConfirmTransaction } = createSolanaClient({urlOrMoniker: "devnet", // or `localnet`, etc},);const wallet = address("nick6zJc6HpW3kfBm4xS2dmbuVRyb5F3AnUvj5ymzR5");const { value: initialBalance } = await rpc.getBalance(wallet).send();console.log("Initial balance:", initialBalance);/*** Note: the `devnet` and `testnet` clusters are subject to rate limits.* it is strongly recommended to use `localnet` and the local test validator*/await airdropFactory({ rpc, rpcSubscriptions })({commitment: "confirmed",lamports: lamports(LAMPORTS_PER_SOL), // request 1 SOL airdroprecipientAddress: wallet,});const { value: newBalance } = await rpc.getBalance(wallet).send();console.log("New balance:", newBalance);
Is this page helpful?