1

I create token and check token info, here is detail:

{
  mintAuthorityOption: 1,
  mintAuthority: PublicKey [PublicKey(BqqZ2km43V9WqLqSFYejNi87JfmmbBxi1MmyuGCLejkp)] {
    _bn: <BN: a117a573cecbff0a4212c44093e5ca54cad698b3d1775bfd9d0a2a909c96cf6d>
  },
  supply: <BN: 8ac7230489e80000>,
  decimals: 9,
  isInitialized: 1,
  freezeAuthorityOption: 1,
  freezeAuthority: PublicKey [PublicKey(BqqZ2km43V9WqLqSFYejNi87JfmmbBxi1MmyuGCLejkp)] {
    _bn: <BN: a117a573cecbff0a4212c44093e5ca54cad698b3d1775bfd9d0a2a909c96cf6d>
  }
}

then I revoke freeze authority with code below:

await createSetAuthorityInstruction(
        token,
        web3Wallet.publicKey,
        AuthorityType.FreezeAccount,
        null
    );

and check token info, here is detail after:

{
  mintAuthorityOption: 1,
  mintAuthority: PublicKey [PublicKey(BqqZ2km43V9WqLqSFYejNi87JfmmbBxi1MmyuGCLejkp)] {
    _bn: <BN: a117a573cecbff0a4212c44093e5ca54cad698b3d1775bfd9d0a2a909c96cf6d>
  },
  supply: <BN: 8ac7230489e80000>,
  decimals: 9,
  isInitialized: 1,
  freezeAuthorityOption: 0,
  freezeAuthority: PublicKey [PublicKey(BqqZ2km43V9WqLqSFYejNi87JfmmbBxi1MmyuGCLejkp)] {
    _bn: <BN: a117a573cecbff0a4212c44093e5ca54cad698b3d1775bfd9d0a2a909c96cf6d>
  }
}

Only freezeAuthorityOption changed, what I expected is freezeAuthority can change as well, like:

...
freezeAuthorityOption: 1,
  freezeAuthority: PublicKey [PublicKey(11111111111111111111111111111111)] {
    _bn: <BN: 0>
  }
...

I m using @metaplex-foundation/mpl-token-metadata to create token, please help

1

1 Answer 1

2

Here's the different ways to do this.

You have to set the new authority as null. This also applies when you want to revoke the mint authority as well.

Using @solana/spl-token

 
import { AuthorityType, createSetAuthorityInstruction } from "@solana/spl-token";
import {
    clusterApiUrl,
    Connection,
    PublicKey,
    sendAndConfirmTransaction,
    Transaction,
} from "@solana/web3.js";

const DEVNET_ENDPOINT = clusterApiUrl("devnet");
const conn = new Connection(DEVNET_ENDPOINT);

async function revokeFreezeAuth() {
    let signer = Keypair.fromSecretKey(Uint8Array.from([])) // update with correct 8-bit array
    let mint = new PublicKey("UPDATE WITH MINT ADDRESS");
    let currentAuthority = signer.publicKey;

    let freezeAuthIx = createSetAuthorityInstruction(
        mint,
        currentAuthority,
        AuthorityType.FreezeAccount,
        null
    );

    const tx = await new Transaction().add(freezeAuthIx);

    let txHash = await sendAndConfirmTransaction(conn, tx, [signer]);
    console.log(txHash);
}

revokeFreezeAuth().then().catch(console.error);

Rust Anchor

To revoke the mint authority we set the mint authority as None which disables all future mintin. This action is irreversible.

use anchor_lang::prelude::*;
use anchor_spl::token::{
    set_authority, spl_token::instruction::AuthorityType, Mint, SetAuthority, Token,
};

#[derive(Accounts)]
pub struct RevokeFreezeAuth<'info> {
    #[account(mut)]
    pub payer: Signer<'info>,

    #[account(mut)]
    pub mint: Account<'info, Mint>,

    pub token_program: Program<'info, Token>,
    pub system_program: Program<'info, System>,
}

  pub fn revoke_freeze_auth(ctx: Context<RevokeMintAuth>) -> Result<()> {
        let cpi_program = ctx.accounts.token_program.to_account_info();
        let cpi_accounts = SetAuthority {
            account_or_mint: ctx.accounts.mint.to_account_info(),
            current_authority: ctx.accounts.payer.to_account_info(),
        };

        let cpi_ctx = CpiContext::new(cpi_program, cpi_accounts);

        set_authority(cpi_ctx, AuthorityType::FreezeAccount, None)?;

        Ok(())
    }

CLI

spl-token authorize {token_address} freeeze --disable

UMI

required dependencies

npm install \
  @metaplex-foundation/umi \
  @metaplex-foundation/umi-bundle-defaults \
  @solana/web3.js \
  @metaplex-foundation/mpl-token-metadata \
  @metaplex-foundation/mpl-toolbox \
  @solana/web3.js \
import {
    mplTokenMetadata,
} from "@metaplex-foundation/mpl-token-metadata";
import { AuthorityType, setAuthority } from "@metaplex-foundation/mpl-toolbox";
import {
    keypairIdentity,
    publicKey,
    signTransaction,
} from "@metaplex-foundation/umi";
import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";
import { toWeb3JsTransaction } from "@metaplex-foundation/umi-web3js-adapters";
import { clusterApiUrl, Connection } from "@solana/web3.js";

const DEVNET_ENDPOINT = clusterApiUrl("devnet");

const conn = new Connection(DEVNET_ENDPOINT);

const umi = createUmi(DEVNET_ENDPOINT);

const keypair = umi.eddsa.createKeypairFromSecretKey(Uint8Array.from([])); // update with correct 8-bit array of signer secret key 

umi.use(keypairIdentity(keypair)).use(mplTokenMetadata());

async function revokeFreezeAuth() {
    let setAuthTx = await setAuthority(umi, {
        owner: umi.identity,
        owned: publicKey("YOUR MINT ADDRESS"),
        authorityType: AuthorityType.FreezeAccount,
        newAuthority: null,
    }).buildWithLatestBlockhash(umi);

    // sign with the umi transaction
    let signedTX = await signTransaction(setAuthTx, [umi.identity]);

    //convert to web3 js TX
    const web3TX = toWeb3JsTransaction(signedTX);
    let txHash = await conn.sendTransaction(web3TX, { skipPreflight: true });
    console.log(txHash);
}

revokeFreezeAuth().then().catch(console.error);

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.