简体   繁体   English

如何使用 @solana/web3.js 从 Solana 中的自定义令牌中删除铸币权限?

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

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

To prevent any more minting, you'll need set the minting authority to None .为了防止更多的铸币,您需要将铸币权限设置为None In JS, you can simply set the newAuthority to null during your call to setAuthority with authorityType = MintTokens in [1]在 JS 中,您可以在使用 [1] 中的authorityType = MintTokens调用setAuthority期间简单地将newAuthority设置为null

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

Expanding on Jon Cinque's answer扩展 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])

})()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 phantom @solana/web3.js 在主网上发送自定义令牌 - Send a custom token on mainnet using phantom @solana/web3.js 如何通过“@solana/web3.js”和“@solana/sol-wallet-adapter”传输自定义 SPL 令牌 - How to transfer custom SPL token by '@solana/web3.js' and '@solana/sol-wallet-adapter' 使用 @solana/web3.js 将元数据添加到 Solana 令牌 - Add Meta Data To Solana Token with @solana/web3.js 如何通过“@solana/web3.js”和“@solana/spl-token”调用 nft 程序? - How to make a call to nft programs by '@solana/web3.js' and "@solana/spl-token"? 如何使用 Web3.js 通过 Solana Pay 连接虚拟钱包? - How to connect phantom wallet by Solana Pay using Web3.js? 如何使用 solana web3 js 在 solana 中获取令牌的符号/名称? - how can i get the symbol/name of a token in solana using solana web3 js? Solana/Web3.js:@Solana/web3.js 是否支持 Solana 当前价格? - Solana/Web3.js: Does @Solana/web3.js support the current price for Solana? 如何在@solana/web3.js 交易中指定最高费用 - How to specify max fee in @solana/web3.js Transaction 如何使用虚拟钱包和 solana web3js 转移 NFT spl-token - How to transfer NFT spl-token using phantom wallet and solana web3js Solana:使用 Js 从 NFT 代币获取 Candy Machine 信息 - Solana: Get Candy Machine info from a NFT token using Js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM