-
Notifications
You must be signed in to change notification settings - Fork 0
/
Newfile.js
32 lines (26 loc) · 964 Bytes
/
Newfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const {
Connection,
LAMPORTS_PER_SOL,
clusterApiUrl, // whom to connnect
Keypair, // create public and private key
} = require("@solana/web3.js");
const connection = new Connection(clusterApiUrl("devnet"), "confirmed"); // confirmation of connection
(async () => {
const keypair = Keypair.generate(); // generate public and private key
const airdropSignature = await connection.requestAirdrop(
keypair.publicKey,
LAMPORTS_PER_SOL // only one sole == one billion lamports (aton)
);
const latestBlockHash = await connection.getLatestBlockhash(); // recent transaction
const txn = await connection.confirmTransaction({
blockhash: latestBlockHash.blockhash,
lastValidBlockHeight: latestBlockHash.lastValidBlockHeight,
signature: airdropSignature,
});
console.log({
publicKey: keypair.publicKey,
privateKey: keypair.secretKey,
signature: airdropSignature,
txn,
});
})();