Skip to main content

Burn Native Tokens

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

danger

If you burn your native tokens, you will not be able to destroy the foundry that created them. If you want to destroy the foundry in the future, you should consider melting your native tokens

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 1 native tokens of the supplied ID.
Dotenv

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

wallet/examples/13_burn_native_token.rs
loading...

Run the example by running the following command:

cargo run --example burn_native_token --release

Expected Output

Balancebeforeburning:

AccountBalance{
base_coin: BaseCoinBalance{
total: 209995515000,
available: 209995515000
},
required_storage_deposit: 1787500,
native_tokens: [
NativeTokensBalance{
token_id: TokenId(0x08adbd5f0844fdc9bf4eafe2df929ac42cc90336e68da284cce96f22523bd87cde0300000000),
total: 100,
available: 100
}
],
nfts: [

],
aliases: [
AliasId(0xadbd5f0844fdc9bf4eafe2df929ac42cc90336e68da284cce96f22523bd87cde)
],
foundries: [
FoundryId(0x08adbd5f0844fdc9bf4eafe2df929ac42cc90336e68da284cce96f22523bd87cde0200000000),
FoundryId(0x08adbd5f0844fdc9bf4eafe2df929ac42cc90336e68da284cce96f22523bd87cde0100000000),
FoundryId(0x08adbd5f0844fdc9bf4eafe2df929ac42cc90336e68da284cce96f22523bd87cde0300000000)
],
potentially_locked_outputs: {
OutputId(0x452a212cbe8512ea7844759402f1679bc1c1e6a088f1f3faaed6aeaa0ac246ee0000): false,
OutputId(0xb8572c3386616ae4be668a46756fcc46bf9cdf178bd50122cf70c81dbec362200000): false,
OutputId(0x041a90dc4d9b23a3ef91c64b7aa69da27e90d3306f644fc7b1647016925d5ff30000): false,
OutputId(0xcb30fa5cbb34b7bb10c0408b4e2bbe323b73fcb9b30b0a9446c1866210cf82d80000): false,
OutputId(0x2c0a9874a309ac3ffce684a8d5f38be54f12760d40ef8fd72f043a11fd4b76110000): false
}
}

Balanceafterburning:

AccountBalance{
base_coin: BaseCoinBalance{
total: 209995515000,
available: 209995515000
},
required_storage_deposit: 1787500,
native_tokens: [
NativeTokensBalance{
token_id: TokenId(0x08adbd5f0844fdc9bf4eafe2df929ac42cc90336e68da284cce96f22523bd87cde0300000000),
total: 99,
available: 99
}
],
nfts: [

],
aliases: [
AliasId(0xadbd5f0844fdc9bf4eafe2df929ac42cc90336e68da284cce96f22523bd87cde)
],
foundries: [
FoundryId(0x08adbd5f0844fdc9bf4eafe2df929ac42cc90336e68da284cce96f22523bd87cde0200000000),
FoundryId(0x08adbd5f0844fdc9bf4eafe2df929ac42cc90336e68da284cce96f22523bd87cde0100000000),
FoundryId(0x08adbd5f0844fdc9bf4eafe2df929ac42cc90336e68da284cce96f22523bd87cde0300000000)
],
potentially_locked_outputs: {
OutputId(0x2c0a9874a309ac3ffce684a8d5f38be54f12760d40ef8fd72f043a11fd4b76110000): false,
OutputId(0x452a212cbe8512ea7844759402f1679bc1c1e6a088f1f3faaed6aeaa0ac246ee0000): false,
OutputId(0x041a90dc4d9b23a3ef91c64b7aa69da27e90d3306f644fc7b1647016925d5ff30000): false,
OutputId(0xb8572c3386616ae4be668a46756fcc46bf9cdf178bd50122cf70c81dbec362200000): false,
OutputId(0xcb30fa5cbb34b7bb10c0408b4e2bbe323b73fcb9b30b0a9446c1866210cf82d80000): false
}
}