chris
chris

Reputation: 600

Solana web3.js set mint and freeze authority null

Trying to set mint and freeze authority of my instruction to null but I get an error

TypeError: Cannot read property 'toBuffer' of null
    at pubkeyToBuffer (/node_modules/@solana/spl-token/lib/index.cjs.js:73:39)

Here's the code

Token.createInitMintInstruction(
   TOKEN_PROGRAM_ID, // program id
   mint.publicKey, // mint
   decimals, // decimals
   null, // mint Authority
   null, // freeze Authority
)

How can I do this? If possible without updating after creation.

Upvotes: 1

Views: 2115

Answers (1)

chris
chris

Reputation: 600

Ok solved it by updating the authority after mint via another 2 instructions for each authority type. Strange nonetheless this apparently can't be done on initial mint instruction.

Token.createSetAuthorityInstruction(
   TOKEN_PROGRAM_ID, // program id
   account, // account
   null, // new authority
   'MintTokens', // type - 'FreezeAccount' for freeze authority
   authority, // authority
   [], // signers
)

Upvotes: 3

Related Questions