Skip to main content

Destroy a Foundry

You can destroy a foundry by calling the Account.destroy_foundry(foundry_id, options) function. The function will destroy a foundry output as long as its circulating native token supply is zero. Any native tokens which were minted by other foundries will be sent to the controlling alias.

Code Example

Before you run the example you should update the foundry_id to one available in your account that has no available native tokens. If you have no available foundries, you can create one by minting a native token. If you've already minted your tokens but need to empty the foundry, you can decrease your native token supply by melting them.

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. Destroy a foundry output by id.
  5. Get the account's balance again to show the difference after step 4.
Dotenv

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

wallet/examples/15_destroy_foundry.rs
loading...

Run the example by running the following command:

cargo run --example destroy_foundry --release

Expected Output

Balancebeforedestroying: AccountBalance{
base_coin: BaseCoinBalance{
total: 109999491000,
available: 109999491000
},
required_storage_deposit: 3046500,
native_tokens: [
...
],
nfts: [
...
]
aliases: [
...
],
foundries: [
FoundryId(0x086d7755dc84a6757ea28285990ddac2eb53f558f8345507ac76d0c33caacaf8970100000000),
],
potentially_locked_outputs: {
...
}
}Balanceafterdestroying: AccountBalance{
base_coin: BaseCoinBalance{
total: 109999491000,
available: 109999491000
},
required_storage_deposit: 3046500,
native_tokens: [
...
],
nfts: [
...
]
aliases: [
...
],
foundries: [
],
potentially_locked_outputs: {
...
}
}