拿測試幣

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: 2022/9/23 下午6:56:02
Contributors: Yihau Chen