0

I am trying create an NFT mint, I know how to do it from CLI, but I need to do it from JS, I am looking at the code of @solana/spl-token package, but cannot find API analogous to

spl-token authorize <TOKEN_ID> mint --disable

Does anyone know how to do it?

1 Answer 1

4

You certainly can! Here's some code that doesn't compile to get you started:

import { Connection, PublicKey, Keypair } from '@solana/web3.js';
import { AuthorityType, setAuthority } from '@solana/spl-token';

const mint = new PublicKey("mint in base 58");
const payer = new Keypair(...);
const mintAuthority = new Keypair(...);
const connection = new Connection
await setAuthority(
    connection,
    payer,
    mint,
    mintAuthority,
    AuthorityType.MintTokens,
    null, // this sets the mint authority to null
);

Adapted from https://github.com/solana-labs/solana-program-library/blob/7c7507f4ec1f320bbc33af459d4d8b5573a6a906/token/js/test/e2e/setAuthority.test.ts#L88

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.