Skip to main content

Melt Native Tokens

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

If you melt your native tokens, you can still destroy the foundry that created them.

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

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

wallet/examples/11_decrease_native_token_supply.rs
loading...

Run the example by running the following command:

cargo run --example melt_native_token --release

Expected Output