-
Notifications
You must be signed in to change notification settings - Fork 94
/
createNFT.cjs
32 lines (26 loc) · 926 Bytes
/
createNFT.cjs
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 {
Metaplex,
keypairIdentity,
bundlrStorage,
} = require("@metaplex-foundation/js");
const { Connection, clusterApiUrl, Keypair } = require("@solana/web3.js");
const fs = require("fs");
const pathToMyKeypair = process.env.HOME + "/.config/solana/id.json";
const keypairFile = fs.readFileSync(pathToMyKeypair);
const secretKey = Buffer.from(JSON.parse(keypairFile.toString()));
const myKeyPair = Keypair.fromSecretKey(secretKey);
const connection = new Connection(clusterApiUrl("devnet"));
const metaplex = Metaplex.make(connection)
.use(keypairIdentity(myKeyPair))
.use(bundlrStorage({ address: "https://devnet.bundlr.network" }));
const uploadNFT = async () => {
const { uri } = await metaplex.nfts().uploadMetadata({
name: "Metadata NFT",
});
const { nft } = await metaplex.nfts().create({
name: "First NFT",
uri: uri,
});
console.log(nft.mint.address.toBase58());
};
uploadNFT();