Skip to main content

NFT Burn

info

A newer version of this page is available in the Developer Hub. Click here to read it.

Overview

The NFT Burn guard restricts the mint to holders of a predefined NFT Collection and burns the holder's NFT. Thus, the mint address of the NFT to burn must be provided by the payer when minting.

CandyMachinesV3-GuardsNFTBurn.png

Guard Settings

The NFT Burn guard contains the following settings:

  • Required Collection: The mint address of the required NFT Collection. The NFT we use to mint with must be part of this collection.

JavaScript — Umi library (recommended)

Here’s how we can set up a Candy Machine using the NFT Burn guard.

create(umi, {
// ...
guards: {
nftBurn: some({ requiredCollection: requiredCollectionNft.publicKey }),
},
});

API References: create, NftBurn

JavaScript — SDK

Here’s an example of how to set up a Candy Machine using the NFT Burn guard.

const { candyMachine } = await metaplex.candyMachines().create({
// ...
guards: {
nftBurn: {
requiredCollection: requiredCollectionNft.address,
},
},
});

API References: Operation, Input, Output, Transaction Builder, Guard Settings.

Mint Settings

The NFT Burn guard contains the following Mint Settings:

  • Required Collection: The mint address of the required NFT Collection.
  • Mint: The mint address of the NFT to burn. This must be part of the required collection and must belong to the minter.
  • Token Standard: The token standard of the NFT to burn.
  • Token Account (optional): You may optionally provide the token account linking the NFT with its owner explicitly. By default, the associated token account of the payer will be used.

Note that, if you’re planning on constructing instructions without the help of our SDKs, you will need to provide these Mint Settings and more as a combination of instruction arguments and remaining accounts. See the Candy Guard’s program documentation for more details.

JavaScript — Umi library (recommended)

You may pass the Mint Settings of the NFT Burn guard using the mintArgs argument like so.

import { TokenStandard } from "@metaplex-foundation/mpl-token-metadata";

mintV2(umi, {
// ...
mintArgs: {
nftBurn: some({
requiredCollection: requiredCollectionNft.publicKey,
mint: nftToBurn.publicKey,
tokenStandard: TokenStandard.NonFungible,
}),
},
});

API References: mintV2, NftBurnMintArgs

JavaScript — SDK

When minting via the JS SDK, simply provide the mint address of the NFT to burn via the mint attribute like so.

Note that the JS SDK does not require the Required Collection to be passed in since it can get it from the provided Candy Machine model. It also does not require the Token Standard as it does not support minting Programmable NFTs.

const { nft } = await metaplex.candyMachines().mint({
// ...
guards: {
nftBurn: {
mint: nftToBurn.address,
},
},
});

You may also provide the tokenAccount attribute explicitly should the NFT not use an associated token account.

API References: Operation, Input, Output, Transaction Builder, Mint Settings.

Route Instruction

The NFT Burn guard does not support the route instruction.