How do I remove the minting authority from my custom token in Solana using @solana/web3.js?

Viewed 1599

I have been able to create custom tokens using custom wallets generated using web3.Keypair.generate(), but how do I now cap the supply of these tokens or remove the minting authority of these SPL tokens?

2 Answers

Expanding on Jon Cinque's answer

import { Connection, clusterApiUrl, Keypair, PublicKey } from '@solana/web3.js'
import { Token, TOKEN_PROGRAM_ID } from '@solana/spl-token'
import * as bs58 from 'bs58';

(async () => {
  const connection = new Connection(clusterApiUrl('mainnet-beta'))

  const bytes = bs58.decode(process.env.PRIVATE_KEY)
  const account = Keypair.fromSecretKey(bytes)

  const tokenMint = new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')
  const token = new Token(connection, tokenMint, TOKEN_PROGRAM_ID, account)

  await token.setAuthority(tokenMint, null, 'MintTokens', account.publicKey, [account])

})()
Related