-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.ts
99 lines (82 loc) · 2.75 KB
/
app.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";
import {
createV1,
mplCore,
createCollectionV1,
pluginAuthorityPair,
ruleSet,
} from "@metaplex-foundation/mpl-core";
import {
TransactionBuilderSendAndConfirmOptions,
createSignerFromKeypair,
generateSigner,
Keypair as umiKeypair,
signerIdentity,
} from "@metaplex-foundation/umi";
import type { PublicKey as umiPublicKey } from "@metaplex-foundation/umi-public-keys";
import { Keypair as web3Keypair, Connection } from "@solana/web3.js";
import { mykey, collection } from "./config/config.json";
import { name, uri } from "./config/nftData.json";
//create UMI to connect solana devnet.
const umi = createUmi("https://api.devnet.solana.com", "processed").use(
mplCore()
);
//get the umiKeypair from keypair json file
const WALLET = web3Keypair.fromSecretKey(new Uint8Array(mykey));
const wallet_publicKey: umiPublicKey =
WALLET.publicKey.toBase58() as umiPublicKey;
const COLLECTION = web3Keypair.fromSecretKey(new Uint8Array(collection));
const collection_publicKey: umiPublicKey =
COLLECTION.publicKey.toBase58() as umiPublicKey;
const payer_keypair: umiKeypair = {
publicKey: wallet_publicKey,
secretKey: WALLET.secretKey,
};
const collection_keypair: umiKeypair = {
publicKey: collection_publicKey,
secretKey: COLLECTION.secretKey,
};
//make accounts' addresses for umi
const payer = createSignerFromKeypair(umi, payer_keypair); //my wallet address
const asset = generateSigner(umi); // new token account address
//make collection address for umi
const collectionAddress = createSignerFromKeypair(umi, collection_keypair);
//determine signer in umi
umi.use(signerIdentity(payer));
const txConfig: TransactionBuilderSendAndConfirmOptions = {
send: { skipPreflight: true },
confirm: { commitment: "processed" },
};
async function main() {
await createCollectionV1(umi, {
name: "Quick Collection",
uri: "https://your.domain.com/collection.json",
collection: collectionAddress,
updateAuthority: payer.publicKey,
plugins: [
pluginAuthorityPair({
type: "Royalties",
data: {
basisPoints: 300,
creators: [
{
address: payer.publicKey,
percentage: 100,
},
],
ruleSet: ruleSet("None"), // Compatibility rule set
},
}),
],
}).sendAndConfirm(umi, txConfig);
console.log("collection creating success");
await createV1(umi, {
name: name,
uri: uri,
asset: asset,
collection: collectionAddress.publicKey,
authority: payer,
}).sendAndConfirm(umi, txConfig);
console.log("token minting success");
}
main().catch(console.error);