Request Airdrop

import { Connection, Keypair } from "@solana/web3.js";
import * as bs58 from "bs58";

// connection
const connection = new Connection("https://api.devnet.solana.com");

// 5YNmS1R9nNSCDzb5a7mMJ1dwK9uHeAAF4CmPEwKgVWr8
const feePayer = Keypair.fromSecretKey(
  bs58.decode("588FU4PktJWfGfxtzpAAXywSNt74AvtroVzGfKkVN1LwRuvHwKGr851uH8czM5qm4iqLbs1kKoMKtMJG4ATR7Ld2")
);

(async () => {
  // 1e9 lamports = 10^9 lamports = 1 SOL
  let txhash = await connection.requestAirdrop(feePayer.publicKey, 1e9);
  console.log(`txhash: ${txhash}`);
})();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Last Updated: 9/23/2022, 6:56:02 PM
Contributors: Yihau Chen