Burn Native Tokens
Burning native tokens refers to the permanent removal or destruction of those tokens from circulation. It renders the tokens unusable and reduces their total supply, often done to maintain scarcity, increase the value of remaining tokens, or enforce specific rules within an ecosystem.
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.
Example Code
- Rust
- Typescript (Node.js)
- Python
The following example will:
- Instantiate a
Wallet
, get Alice'sAccount
which was created in the first guide and sync it. - Search the account's balance for a native token with a balance of at least
MIN_AVAILABLE_AMOUNT
(to be able to burn BURN_AMOUNT).
- Burn the native tokens by calling the
Account.burn()
function.
The following example will:
- Instantiate a
Wallet
, get Alice'sAccount
which was created in the first guide and sync it. - Search the account's balance for a native token with a balance of at least
MIN_AVAILABLE_AMOUNT
.
- Prepare the transaction that will burn the tokens using the
Account.prepareBurnNativeToken()
function and send the prepared transaction using theAccount.send()
function.
The following example will:
- Instantiate a
Wallet
, get Alice'sAccount
which was created in the first guide and sync it. - Search the account's balance for a native token with a balance of at least 10.
- Prepare the transaction that will burn the tokens using the
Account.prepare_burn_native_token()
function and send the prepared transaction using theAccount.send()
function.
Full Example Code
- Rust
- Typescript (Node.js)
- Python
sdk/examples/how_tos/native_tokens/burn.rs
loading...
bindings/nodejs/examples/how_tos/native_tokens/burn.ts
loading...
bindings/python/examples/how_tos/native_tokens/burn.py
loading...
Expected Output
Balance before burning: 30
Transaction sent: 0x8c93b86b003b0476266f1d4d0c486dfcbbb72d4991eb5d63d5466a6cad93e9f2
Block included: https://explorer.shimmer.network/testnet/block/0x49e2ec7ac5a88b1b0ffcde20bff437b53ef74f38368c28af402435f45dd5b138
Balance after burning: 29