-
Notifications
You must be signed in to change notification settings - Fork 1
/
revokeMintAuthority.ts
41 lines (32 loc) · 1.17 KB
/
revokeMintAuthority.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
// Script to remove mint authority from token and make a fix supply:
const { Connection, PublicKey, Keypair } = require('@solana/web3.js');
const { AuthorityType, setAuthority } = require('@solana/spl-token');
import { getAdminAccount } from '../lib/helpers';
import {connection } from "../lib/vars";
import { loadPublicKeysFromFile } from '../lib/helpers';
(async()=>{
console.log("====== Processing Mint Revoke=======");
const adminAccountPrivKey = process.env.ADMIN_PRIV_KEY;
const adminAccount = getAdminAccount(adminAccountPrivKey);
// load the stored PublicKeys for ease of use
let localKeys = loadPublicKeysFromFile();
// ensure the desired script was already run
if (!localKeys?.tokenMint)
return console.warn("No local keys were found. Please run '3.createTokenWithMetadata.ts'");
const tokenMint = new PublicKey(localKeys.tokenMint);
try{
const tx = await setAuthority(
connection,
adminAccount,
tokenMint,
adminAccount,
AuthorityType.MintTokens,
null, // this sets the mint authority to null
);
console.log("revoke tx: ",tx)
}
catch(error){
console.log("Error:",error);
}
console.log("Completed");
})()