-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmint-token.ts
29 lines (20 loc) · 936 Bytes
/
mint-token.ts
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
import { getExplorerLink, getKeypairFromEnvironment } from "@solana-developers/helpers";
import { mintTo } from "@solana/spl-token";
import { Connection, PublicKey, clusterApiUrl } from "@solana/web3.js";
import dotenv from "dotenv";
dotenv.config();
const connection = new Connection(clusterApiUrl("devnet"));
const MINOR_UNITS_PER_MAJOR_UNITS = Math.pow(10, 2);
const user = getKeypairFromEnvironment("SECRET_KEY");
const tokenMintAccount = new PublicKey("5vS9WmsywxrTFm8nQeESNBdNsLodNEvoyeDPcHHzjm2u");
const recipientAssocciatedTokenAccount = new PublicKey("95FbMGEhzcZWnVcFV7VFBCmMe9yXseq1Fg3L6qauLs2y");
const transactionSignature = await mintTo(
connection,
user,
tokenMintAccount,
recipientAssocciatedTokenAccount,
user,
10 * MINOR_UNITS_PER_MAJOR_UNITS
);
const link = getExplorerLink("transaction", transactionSignature, "devnet");
console.log(`✅ Success~ Mint Token Transaction: ${link}`);