-
Notifications
You must be signed in to change notification settings - Fork 0
/
token-multisig-mint-revoke.ts
71 lines (60 loc) · 1.6 KB
/
token-multisig-mint-revoke.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
import { Transaction, Connection, PublicKey } from "@solana/web3.js";
import {
createMintToInstruction,
createSetAuthorityInstruction,
createAssociatedTokenAccountInstruction,
getAssociatedTokenAddress,
AuthorityType,
} from "@solana/spl-token";
import * as bs58 from "bs58";
const url = "https://api.mainnet-beta.solana.com";
/*
* 1 Create ATA for multisig
* 2. Mint 1B Token
* 3. Revoke authority
*/
let tokenAddress = new PublicKey("ZEXy1pqteRu3n13kdyh4LwPQknkFk3GzmMYMuNadWPo"); // Multisig
let multisigAddress = new PublicKey(
"Bs5XaFx9wS8N5ir4QtTb2exhFMKQdZUmjga1peT2DBXt"
);
async function main() {
let connection = new Connection(url, "processed");
let tokenAccountAddress = await getAssociatedTokenAddress(
tokenAddress,
multisigAddress,
true
);
let mintTx = new Transaction();
mintTx.add(
createAssociatedTokenAccountInstruction(
multisigAddress,
tokenAccountAddress,
multisigAddress,
tokenAddress
)
);
mintTx.add(
createMintToInstruction(
tokenAddress,
tokenAccountAddress,
multisigAddress,
1_000_000_000_000_000
)
);
mintTx.add(
createSetAuthorityInstruction(
tokenAddress,
multisigAddress,
AuthorityType.MintTokens,
null
)
);
const blockhash = await connection.getRecentBlockhash("processed");
// This isn't used, just required for serialization.
mintTx.recentBlockhash = blockhash.blockhash;
mintTx.feePayer = multisigAddress;
const rawTx = mintTx.serializeMessage();
let mintTxString = bs58.encode(rawTx);
console.log(`MintTX: ${mintTxString}`);
}
main();