current location:Home >> Blockchain knowledge >> how to freeze an nft on solana?

how to freeze an nft on solana?

admin Blockchain knowledge 507

Freezing an NFT on Solana is a crucial action taken by the creator or update authority to make the NFT immutable. Once frozen, its metadata (name, image, properties, etc.) can never be changed again.

how to freeze an nft on solana?

This is a technical process that requires using Solana command-line tools or writing code. There is no button to click in a standard wallet like Phantom or Solflare. It's primarily a developer-oriented action.

Here’s a breakdown of how it works and the steps to do it.

Key Concepts First

  1. What is Freezing? In Solana, an NFT is a Token with associated Metadata. This metadata is stored in an account owned by the Metaplex Token Metadata program. "Freezing" means setting the is_mutable attribute in this metadata account to false.

  2. Who Can Freeze? Only two authorities can freeze an NFT:

    • The Update Authority (usually the original creator or collection admin).

    • The Metadata Delegate (if one has been explicitly granted permission by the update authority).

  3. Permanence: This action is irreversible. Once an NFT is frozen, no one, not even the update authority, can ever change its metadata.


Method 1: Using Sugar (The Recommended Way for Creators)

Sugar is a command-line tool created by Metaplex for managing NFT candy machines and collections. It's the simplest way to freeze NFTs, especially if you minted with a Candy Machine.

Prerequisites:

  • Node.js and npm installed.

  • Your wallet's keypair file (e.g., id.json) that is the update authority for the NFT.

  • The Mint Address of the NFT you want to freeze.

Steps:

  1. Install Sugar:

    bash
    sh -c "$(curl -sSfL https://release.solana.com/v1.18.4/install)"export PATH="~/.local/share/solana/install/active_release/bin:$PATH"curl -sSf https://raw.githubusercontent.com/metaplex-foundation/sugar/main/install | bash
  2. Run the Freeze Command:
    Use the sugar freeze command, providing the mint address and the path to your keypair.

    bash
    sugar freeze <MINT_ADDRESS> -k ~/path/to/your/update-authority-keypair.json

    Replace <MINT_ADDRESS> with the actual mint address (e.g., 7XZ...9d8).

  3. Confirm the Transaction:
    The tool will ask for confirmation and then send the transaction to the network. If successful, the NFT is now permanently frozen.


Method 2: Using the solana-program-library CLI Tool

This method uses a more general CLI tool provided by Solana.

Prerequisites:

  • The spl-token CLI tool installed (cargo install spl-token-cli).

  • Your update authority keypair.

Steps:

  1. Run the Command:
    The command structure uses the Metaplex Token Metadata program to update the field.

    bash
    spl-token --program-id metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s authorize <MINT_ADDRESS> freeze --disable
    • <MINT_ADDRESS> is your NFT's mint address.

    • The --disable flag is what sets is_mutable to false.

  2. Sign the Transaction:
    The CLI will use your default Solana CLI keypair. If your update authority keypair is different, you must specify it with the --keypair or -k flag:

    bash
    spl-token --keypair ~/path/to/your/update-authority-keypair.json --program-id metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s authorize <MINT_ADDRESS> freeze --disable

Method 3: Programmatically with TypeScript (Using @metaplex-foundation/js)

This is the method for developers who want to integrate freezing into their own applications or scripts.

Prerequisites:

  • A Node.js project.

  • Install the Metaplex JS SDK: npm install @metaplex-foundation/js @solana/web3.js

Example Code:

javascript
import { Metaplex, keypairIdentity } from "@metaplex-foundation/js";import { Connection, clusterApiUrl, Keypair } from "@solana/web3.js";import * as fs from 'fs';// 1. Set up connection and identityconst connection = new Connection(clusterApiUrl('mainnet-beta')); // Use 'devnet' for testingconst keypairFile = JSON.parse(fs.readFileSync('path/to/your/update-authority-keypair.json', 'utf-8'));const wallet = Keypair.fromSecretKey(new Uint8Array(keypairFile));const metaplex = Metaplex.make(connection).use(keypairIdentity(wallet));async function freezeNft(mintAddress) {
  try {
    // 2. Fetch the NFT object
    const nft = await metaplex.nfts().findByMint({ mintAddress });

    // 3. Freeze the NFT by updating it and setting isMutable to false
    const { response } = await metaplex.nfts().update({
      nftOrSft: nft,
      isMutable: false, // This is the crucial line
    });

    console.log(`✅ Success! NFT Frozen.`);
    console.log(`Transaction Signature: ${response.signature}`);

  } catch (error) {
    console.error("❌ Failed to freeze NFT:", error);
  }}// Replace with your NFT's mint addressconst myNftMintAddress = "7XZ...9d8"; freezeNft(myNftMintAddress);

How to Verify an NFT is Frozen

You can easily check the frozen status of any NFT using a Solana explorer:

  1. Go to Solana FM or Solscan.

  2. Paste the NFT's mint address into the search bar.

  3. Look at the metadata section. You should see a field called Is Mutable or Mutable.

  4. If it says No or False, the NFT is successfully frozen.

Important Considerations

  • Cost: Freezing an NFT requires a transaction fee (a fraction of a SOL) and may require a small rent fee for the metadata account, though this is often negligible.

  • Responsibility: Freezing is a sign of trust and finality. Do not freeze an NFT until you are 100% certain the metadata is correct and permanent.

  • Collection Verification: For a collection to be verified on marketplaces like Magic Eden, the collection NFT itself usually needs to be frozen, signaling to the marketplace that the entire collection's structure is final and cannot be rug-pulled.

For most users who are not developers, working with the original creator or a developer who has access to the update authority keypair is the necessary path to get an NFT frozen.

If you have any questions or uncertainties, please join the official Telegram group: https://t.me/GToken_EN

GTokenTool

GTokenTool is the most comprehensive one click coin issuance tool, supporting multiple public chains such as TON, SOL, BSC, etc. Function: Create tokensmarket value managementbatch airdropstoken pre-sales IDO、 Lockpledge mining, etc. Provide a visual interface that allows users to quickly create, deploy, and manage their own cryptocurrencies without writing code.

Similar recommendations