1

我已经能够使用使用 web3.Keypair.generate() 生成的自定义钱包创建自定义令牌,但是我现在如何限制这些令牌的供应或删除这些 SPL 令牌的铸造权限,可以这么说?

4

2 回答 2

2

为了防止更多的铸币,您需要将铸币权限设置为None. 在 JS 中,您可以在调用[1]期间简单newAuthority地将nullsetAuthorityauthorityType = MintTokens

[1] https://github.com/solana-labs/solana-program-library/blob/36e886392b8c6619b275f6681aed6d8aae6e70f9/token/js/client/token.js#L985

于 2021-09-07T19:13:34.857 回答
1

扩展 Jon Cinque 的答案

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])

})()
于 2021-09-09T08:03:29.250 回答