-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate-mint.ts
More file actions
42 lines (38 loc) · 1.11 KB
/
create-mint.ts
File metadata and controls
42 lines (38 loc) · 1.11 KB
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
33
34
35
36
37
38
39
40
41
42
import "dotenv/config";
import { Keypair } from "@solana/web3.js";
import { createRpc } from "@lightprotocol/stateless.js";
import {
createMintInterface,
createTokenMetadata,
} from "@lightprotocol/compressed-token";
import { homedir } from "os";
import { readFileSync } from "fs";
// devnet:
// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`;
// const rpc = createRpc(RPC_URL);
// localnet:
const rpc = createRpc();
const payer = Keypair.fromSecretKey(
new Uint8Array(
JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8"))
)
);
(async function () {
const { mint, transactionSignature } = await createMintInterface(
rpc,
payer,
payer,
null,
9,
undefined, // keypair
undefined, // confirmOptions (default)
undefined, // programId (CTOKEN_PROGRAM_ID)
createTokenMetadata(
"Example Token",
"EXT",
"https://example.com/metadata.json"
)
);
console.log("Mint:", mint.toBase58());
console.log("Tx:", transactionSignature);
})();