-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate_collection.ts
67 lines (55 loc) · 2.51 KB
/
create_collection.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
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
// Import necessary modules from Metaplex and Node.js
import { createCollection, createCollectionV2, ruleSet } from "@metaplex-foundation/mpl-core";
import { generateSigner, keypairIdentity, publicKey } from "@metaplex-foundation/umi";
import { readFile } from 'fs/promises';
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
// Constants
async function main() {
try {
const RPC_ENDPOINT = 'https://api.devnet.solana.com'; // RPC endpoint for Solana Devnet
const WALLET_PATH = 'C:\\Users\\artis\\.config\\solana\\id.json'; // Path to the wallet JSON file
const creator1 = publicKey('GaKuQyYqJKNy8nN9Xf6VmYJQXzQDvvUHHc8kTeGQLL3f')
const creator2 = publicKey('9SuQHwj9p6GDZMusnmqfXovaHxd9z3bQQn8e85fA5ue1')
// Load the default Solana wallet
const walletFile = await readFile(WALLET_PATH, 'utf8');
const wallet = JSON.parse(walletFile);
// Initialize Umi with the chosen RPC endpoint
const umi = createUmi(RPC_ENDPOINT);
const keypair = umi.eddsa.createKeypairFromSecretKey(new Uint8Array(wallet));
// Set the wallet as the identity for transactions
umi.use(keypairIdentity(keypair));
// Generate a new signer for the collection
const collectionSigner = generateSigner(umi);
// Create the collection
await createCollection(umi, {
collection: collectionSigner,
name: 'Core DL v2 Devnet Test',
uri: "https://gateway.irys.xyz/GcQLh6Uq22oLXY4qicnH4bG4SJ3fqtF22PvgKmapYSR5",
plugins: [
{
type: 'Royalties',
basisPoints: 500,
creators: [
{
address: creator1,
percentage: 20,
},
{
address: creator2,
percentage: 80,
},
],
ruleSet: ruleSet('None'), // Compatibility rule set
},
],
}).sendAndConfirm(umi);
// Log the collection address (public key)
const collectionAddress = collectionSigner.publicKey;
console.log('Collection Address:', collectionAddress);
console.log('View on Solscan:', `https://solscan.io/token/${collectionAddress}?cluster=devnet`);
} catch (error) {
console.error('An error occurred:', error);
}
}
// Execute the main function
main();