HTS x EVM - Part 3: How to Pause, Freeze, Wipe, and Delete NFTs
Last updated
Was this helpful?
Last updated
Was this helpful?
In , you learned how to grant / revoke KYC and manage a token using the . But those aren't all the token operations you can do!
In this guide, you will learn how to:
Pause a token (stop all operations)
Freeze a token for a specific account
Wipe NFTs from a specific account
Delete a token
ECDSA account from the .
Basic understanding of Solidity.
Clone the repository
Install dependencies
Create .env
file set up environment variables
Edit the .env
file to include your Hedera Testnet account's private key. Use your ECDSA Hex Encoded Private Key when interacting with Hedera's EVM via the JSON-RPC relay.
Run the test script
This script deploys and tests all of the functionality inside of the PauseFreezeWipeDelete
Smart Contract. We'll deep dive into the Smart Contract's functions and corresponding tests below!
Check out those tutorials for specific details or the contracts/3-PauseFreezeWipeDelete.ts
to see the code for adding the new keys.
pauseToken()
Purpose: Stops all operations (e.g., mint, transfer, burn, etc.) for the token, across every account.
After pausing, we attempt a transfer. The test expects a revert (the transfer fails) because the token is paused.
unpauseToken()
Purpose: Reenables actions to be performed on and with the token
We confirm that normal token operations (e.g., transfers) resume after the unpause
.
freezeAccount(address account)
Purpose: Freezes a specific account, meaning it can neither send nor receive the token. Freezing is more granular than pausing; it only affects a specific account. This is useful for making soul-bound tokens.
We freeze the owner
account.
The test ensures that transferring an NFT to or from this frozen account reverts.
unfreezeAccount(address account)
Purpose: Unfreezes the token for a specific account.
Test Implementation:
After unfreezing, the owner
account can transact freely again.
wipeTokenFromAccount(address account, int64[] serialNumbers)
Purpose: Wiping effectively burns that token (i.e., reduces the total supply) from a non-treasury account.
We specify which serial numbers we want to wipe. The test confirms the TokenWiped
event is emitted upon success.
deleteToken()
Purpose: Renders a token completely unusable for future operations. The token still exists on the ledger (you can query it), but all transactions (e.g., minting, transfers, etc.) will fail. The ADMIN key is required to delete.
Test Implementation:
Once deleted, attempting further operations like minting will fail.
In this guide, you saw how to replicate key HTS operations (pause, freeze, wipe, delete) directly in a Solidity contract by calling the HTS System Contract functions on Hedera. This approach provides fine-grained control via the contract’s ownership and key management, which is especially useful if you need all relevant HTS functionality in a single deployable smart contract.
Key Takeaways:
If you want to perform the respective operations later, you must set the ADMIN, FREEZE, PAUSE, WIPE, and SUPPLY keys when creating a token via a contract.
Any account that needs to receive or send the token must be associated with it.
Pausing affects all operations globally while freezing targets a single account.
Wiping NFTs effectively burns them, reducing total supply.
Deleting a token makes it unusable for future operations but remains queryable on the ledger.
Check out our GitHub repo to find the full contract and Hardhat test scripts, along with the configuration files you need to deploy and test on Hedera!
Make sure to use an ECDSA account with for the test script to run successfully.
These steps of the flow have been covered in the and . The only difference here is that we set a few different keys to handle pausing, freezing, and wiping.
For , specify an amount to wipe; for , we specify the serial numbers to be wiped.
Writer: Jake, Developer Relations Engineer
Editor: Michiel, Developer Relations Engineer
Editor: Krystal, Technical Writer
|
|
|