-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_createCollection.js
More file actions
74 lines (57 loc) · 2.28 KB
/
_createCollection.js
File metadata and controls
74 lines (57 loc) · 2.28 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { createCollection, mplCore } from "@metaplex-foundation/mpl-core";
import {
generateSigner,
keypairIdentity
} from "@metaplex-foundation/umi";
import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";
import { base58 } from "@metaplex-foundation/umi/serializers";
import { irysUploader } from "@metaplex-foundation/umi-uploader-irys";
import fs from "fs";
(async () => {
if( process.argv[2] == null ){
console.log('\tnode createCollection.js <Name>');
return;
}
const name = process.argv.slice(2).join(' ');
const umi = createUmi("https://api.devnet.solana.com")
.use(mplCore())
.use(
irysUploader({
// mainnet address: "https://node1.irys.xyz"
// devnet address: "https://devnet.irys.xyz"
address: "https://devnet.irys.xyz",
})
);
const walletFile = JSON.parse(
fs.readFileSync("./id.json")
);
let keypair = umi.eddsa.createKeypairFromSecretKey(
new Uint8Array(walletFile)
);
umi.use(keypairIdentity(keypair));
//
// ** Creating the Collection **
//
const collection = generateSigner(umi)
console.log('Creating Collection...')
const tx = await createCollection(umi, {
collection,
name: name
}).sendAndConfirm(umi);
const signature = base58.deserialize(tx.signature)[0]
console.log('\Collection Created')
console.log('View Transaction on Solana Explorer')
console.log(`https://explorer.solana.com/tx/${signature}?cluster=devnet`)
console.log("\n");
console.log("View NFT on Metaplex Explorer");
console.log(`https://explorer.solana.com/address/${collection.publicKey}?cluster=devnet`);
})();
// % node createCollection.js LuckySet
// Creating Collection...
// Collection Created
// View Transaction on Solana Explorer
// https://explorer.solana.com/tx/quf7aYaezeTKoR9HWs9fYqMArp6GXkHH5xE4pkGSywCpqzHkGnYD5ggWHohk2MHPtXbQPKdsbc9XKMxutFjKcd8?cluster=devnet
// quf7aYaezeTKoR9HWs9fYqMArp6GXkHH5xE4pkGSywCpqzHkGnYD5ggWHohk2MHPtXbQPKdsbc9XKMxutFjKcd8
// View NFT on Metaplex Explorer
// https://explorer.solana.com/address/AA3iQCFM2yiRyE4EvjsVmkByTkbk4SGAb43JFMfZ9vJe?cluster=devnet
// AA3iQCFM2yiRyE4EvjsVmkByTkbk4SGAb43JFMfZ9vJe