-
Notifications
You must be signed in to change notification settings - Fork 2
/
metaplex.ts
85 lines (76 loc) · 2.49 KB
/
metaplex.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
import {
percentAmount,
generateSigner,
createSignerFromKeypair,
signerIdentity,
publicKey,
} from '@metaplex-foundation/umi';
import {
TokenStandard,
createAndMint,
createMetadataAccountV3,
createV1
} from '@metaplex-foundation/mpl-token-metadata';
import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import { mplCandyMachine } from '@metaplex-foundation/mpl-candy-machine';
import * as dotenv from 'dotenv';
dotenv.config();
import { loadSecretKey, saveSecretKey } from './utils';
import token_metadata from './token.json';
void (async function () {
const signer = await loadSecretKey('signer.key');
const mintKeypair = await loadSecretKey('mint.key');
if (!signer || !mintKeypair) {
process.exit(1);
}
const umi = createUmi(process.env.NODE_ENV == 'production' ? 'https://api.mainnet-beta.solana.com' : 'https://api.devnet.solana.com');
const userWallet = umi.eddsa.createKeypairFromSecretKey(signer.secretKey);
const userWalletSigner = createSignerFromKeypair(umi, userWallet);
const SPL_TOKEN_2022_PROGRAM_ID = publicKey(
'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb'
);
umi.programs.bind('splToken', 'splToken2022');
umi.use(signerIdentity(userWalletSigner));
umi.use(mplCandyMachine());
createV1(umi, {
mint: publicKey(mintKeypair.publicKey.toString()),
name: token_metadata.name,
symbol: token_metadata.symbol,
decimals: 9,
uri: "https://ipfs.io/ipfs/bafkreifgmjlkzzn2ww5w6edegswaz5amcmxofb6johz34s226b6suk6l4m",
sellerFeeBasisPoints: percentAmount(0),
creators: null,
isMutable: true,
tokenStandard: TokenStandard.Fungible,
collection: null,
uses: null,
collectionDetails: null,
ruleSet: null,
payer: userWalletSigner,
updateAuthority: userWalletSigner,
splTokenProgram: SPL_TOKEN_2022_PROGRAM_ID,
})
.sendAndConfirm(umi)
.then(() => {
console.log('Successfully set metadata.');
});
/*
const mint = generateSigner(umi);
createAndMint(umi, {
mint,
authority: umi.identity,
name: token_metadata.name,
symbol: token_metadata.symbol,
decimals: 9,
uri: "https://ipfs.io/ipfs/bafkreifgmjlkzzn2ww5w6edegswaz5amcmxofb6johz34s226b6suk6l4m",
sellerFeeBasisPoints: percentAmount(0),
amount: 100_000_000_000_000,
tokenOwner: userWallet.publicKey,
tokenStandard: TokenStandard.Fungible,
splTokenProgram: SPL_TOKEN_2022_PROGRAM_ID,
})
.sendAndConfirm(umi)
.then(() => {
console.log("Successfully deployed");
});*/
})();