Skip to main content

Burn NFTs

You may want to burn some of your circulating NFTs. To do so, you will need to call the Account.burn_nft(native_token, options) function.

Code Example

Replace the native token ID

Before you run the code example, make sure to update the token ID with one which is available in your account. If you haven't done so already, you can follow the how to mint a native token guide. If you don't know the token ID you can check your accounts balance to retrieve the available native tokens in your account.

The following example will:

  1. Create an account manager.
  2. Get Alice's account which was created in the first guide.
  3. Get the account's balance.
  4. Burn an NFT of the supplied ID.
Dotenv

This example uses dotenv, which is not safe for use in production environments.

wallet/examples/14_burn_nft.rs
loading...

Run the example by running the following command:

cargo run --example burn_nft --release

Expected Output

Balance before burning:
AccountBalance{
base_coin: BaseCoinBalance{
total: 209996955000,
available: 209996955000
},
required_storage_deposit: 902500,
native_tokens: [

],
nfts: [
NftId(0xe314d76664f0ffe8d5fbe670527f108328c14bc8dad89b234dde3ff8deb58ec9)
],
aliases: [

],
foundries: [

],
potentially_locked_outputs: {

}
}
Balance after burning:
AccountBalance{
base_coin: BaseCoinBalance{
total: 209996955000,
available: 209996955000
},
required_storage_deposit: 852000,
native_tokens: [

],
nfts: [

],
aliases: [

],
foundries: [

],
potentially_locked_outputs: {

}
}