Skip to main content

Destroy a Foundry

You can destroy a foundry by calling the Account.burn(burn, options) function. The function will destroy a foundry output as long as its circulating native token supply is zero.

Destroying Foundry

A foundry can only be destroyed (and its storage deposit be claimed) if the circulating supply is zero. Therefore if you control the foundry and want to destroy it in the future, you should consider melting your native tokens instead of burning them.

Code Example

Before you run the example you should make sure the first foundy on your account has zero circulating supply. If you have no available foundries, you can create one by creating a native token. If you've already created your tokens but need to empty the foundry, you can decrease your native token supply by melting them.

The following example will:

  1. Create a wallet.
  2. Get Alice's account which was created in the first guide.
  3. Get the account's balance and show the amount of foundries.
  4. Try to destroy the first foundry output.
  5. Get the account's foundry count again to show the difference after step 4.
sdk/examples/how_tos/native_tokens/destroy_foundry.rs
loading...

Expected Output

Foundries before destroying: 51
Transaction sent: 0xe0930e445aa9e78f59e3979744102bb0980fe6332950c7bb4785700dcb24fe8e
Block included: https://explorer.shimmer.network/testnet/block/0x31d08663ae1d175d798d0f2925f41fa97f0eee8f9e233a4f5dacedb1398ed544
Foundries after destroying: 50