Skip to main content

Token Burn

info

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

Overview

The Token Burn guard allows minting by burning some of the payer’s tokens from a configured mint account. If the payer does not have the required amount of tokens to burn, minting will fail.

CandyMachinesV3-GuardsTokenBurn.png

Guard Settings

The Token Burn guard contains the following settings:

  • Amount: The number of tokens to burn.
  • Mint: The address of the mint account defining the SPL Token we want to burn.

JavaScript — Umi library (recommended)

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

create(umi, {
// ...
guards: {
tokenBurn: some({
amount: 300,
mint: tokenMint.publicKey,
}),
},
});

API References: create, TokenBurn

JavaScript — SDK

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

import { token } from "@metaplex-foundation/js";

const { candyMachine } = await metaplex.candyMachines().create({
// ...
guards: {
tokenBurn: {
amount: token(300),
mint: tokenMint.address,
},
},
});

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

Mint Settings

The Token Burn guard contains the following Mint Settings:

  • Mint: The address of the mint account defining the SPL Token we want to burn.

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 Token Burn guard using the mintArgs argument like so.

mintV2(umi, {
// ...
mintArgs: {
tokenBurn: some({ mint: tokenMint.publicKey }),
},
});

API References: mintV2, TokenBurnMintArgs

JavaScript — SDK

The JS SDK does not require any Mint Settings for the Token Burn guard since it can infer them from the provided Candy Machine model.

Route Instruction

The Token Burn guard does not support the route instruction.