Last updated
Last updated
In of the series, you saw how to mint and transfer an NFT using the Hedera Token Service (HTS). In , you saw how to enable and disable token , update token properties (if a token is mutable), and schedule transactions. In Part 3, you will learn how to use HTS capabilities that help you manage your tokens. Specifically, you will learn how to:
Pause a token (stops all operations for a token ID)
Freeze an account (stops all token operations only for a specific account)
Wipe a token (wipe a partial or entire token balance for a specific account)
Delete a token (the token will remain on the ledger)
We recommend you complete the following introduction to get a basic understanding of Hedera transactions. This example does not build upon the previous examples.
Pausing a token may be useful in cases where a third party requests that you, as the administrator of a token, stop all operations for that token while something like an audit is conducted. The pause transaction provides you with a way to comply with requests of that nature.
Console output:
Console output:
Note: Wiping an account's tokens burns the tokens and decreases the total supply. This transaction does not delete tokens from the treasury account. You must use the Token Burn operation to delete tokens from the treasury.
Console output:
In our example, we delete the token and perform a query to double-check that the deletion was successful. Note that for NFTs, you can’t delete a specific serial ID. Instead, you delete the entire class of the NFT specified by the token ID.
Console output:
Get a .
Set up your environment .
✅ If you want the entire code used for this tutorial, skip to the section below.
The prevents a token from being involved in any kind of operation across all accounts. Specifying a <pauseKey> during the creation of a token is a requirement to be able to pause token operations. The code below shows you that this key must sign the pause transaction. Note that you can’t pause a token if it doesn’t have a pause key. Also keep in mind that if this key was not set during token creation, then a token update to add this key is not possible.
In our example below, we pause the token, test that by trying a token transfer and checking the token pauseStatus, and then we to enable operations again.
stops "freezes" transfers of that token for a specific account ID. Note that this transaction must be signed by the <freezeKey> of the token. Once a freeze executes, the specified account is marked as “Frozen” and will not be able to receive or send tokens unless unfrozen.
In our example below, we first freeze Alice’s account for the token ID we’re working with, test the freeze by trying a token transfer, and then Alice’s account so she can transact the token again.
wipes the provided amount of fungible or non-fungible tokens from the specified account. You see from the code below that this transaction must be signed by the token's <wipeKey>.
In this case, we wipe the NFT that Alice currently holds. We then check Alice’s balance and the NFT supply to see how these change with the wipe operation (these two values before the wipe are provided for comparison – see for the details).
After you , it’s no longer possible to perform any operations for that token, and transactions resolve to the error TOKEN_WAS_DELETED
. Note that the token remains in the ledger, and you can still retrieve some information about it.
The delete operation must be signed by the token <adminKey>. Remember from that if this key is not set during token creation, then the token is immutable and deletion is not possible.
In this article, you saw key capabilities to help you manage your HTS tokens, including how to: pause, freeze, wipe, and delete tokens. If you haven’t already, check out and of this tutorial series to see examples of how to do even more with HTS – you will see how to mint NFTs, transfer NFTs, perform token KYC, schedule transactions, and more.
Continue learning more in our !
➡
➡ Have a question? Ask on