Hedera
Search…
Delete a token
Deleting a token marks a token as deleted, though it will remain in the ledger. The operation must be signed by the specified Admin Key of the Token. If the Admin Key is not set, Transaction will result in TOKEN_IS_IMMUTABlE. Once deleted update, mint, burn, wipe, freeze, unfreeze, grant kyc, revoke kyc and token transfer transactions will resolve to TOKEN_WAS_DELETED.
NFTs
You cannot delete a specific NFT. You can delete the class of the NFT specified by the token ID after you have burned all associated NFTs associated with the token class

Transaction Signing Requirements:

  • Admin key
  • Transaction fee payer account key
Constructor
Description
new TokenDeleteTransaction()
Initializes the TokenDeleteTransaction object
1
new TokenDeleteTransaction()
Copied!

Methods

V2
V1
Method
Type
Description
Requirement
setTokenId(<tokenId>)
TokenId
The ID of the token to delete
Required
Java
1
//Create the transaction
2
TokenDeleteTransaction transaction = new TokenDeleteTransaction()
3
.setTokenId(tokenId);
4
5
//Freeze the unsigned transaction, sign with the admin private key of the account, submit the transaction to a Hedera network
6
TransactionResponse txResponse = transaction.freezeWith(client).sign(adminKey).execute(client);
7
8
//Request the receipt of the transaction
9
TransactionReceipt receipt = txResponse.getReceipt(client);
10
11
//Obtain the transaction consensus status
12
Status transactionStatus = receipt.status;
13
14
System.out.println("The transaction consensus status is " +transactionStatus);
15
16
//v2.0.1
Copied!
JavaScript
1
//Create the transaction and freeze the unsigned transaction for manual signing
2
const transaction = await new TokenDeleteTransaction()
3
.setTokenId(tokenId)
4
.freezeWith(client);
5
6
//Sign with the admin private key of the token
7
const signTx = await transaction.sign(adminKey);
8
9
//Submit the transaction to a Hedera network
10
const txResponse = await signTx.execute(client);
11
12
//Request the receipt of the transaction
13
const receipt = await txResponse.getReceipt(client);
14
15
//Get the transaction consensus status
16
const transactionStatus = receipt.status;
17
18
console.log("The transaction consensus status " +transactionStatus.toString());
19
20
//v2.0.5
Copied!
Go
1
//Create the transaction and freeze the unsigned transaction for manual signing
2
transaction, err = hedera.NewTokenDeleteTransaction().
3
SetTokenID(tokenId).
4
FreezeWith(client)
5
6
if err != nil {
7
panic(err)
8
}
9
10
//Sign with the admin private key of the account, submit the transaction to a Hedera network
11
txResponse, err := transaction.Sign(adminKey).Execute(client)
12
13
if err != nil {
14
panic(err)
15
}
16
17
//Request the receipt of the transaction
18
receipt, err = txResponse.GetReceipt(client)
19
20
if err != nil {
21
panic(err)
22
}
23
24
//Get the transaction consensus status
25
status := receipt.Status
26
27
fmt.Printf("The transaction consensus status is %v\n", status)
28
29
//v2.1.0
Copied!
Method
Type
Description
Requirement
setTokenId(<tokenId>)
TokenId
The ID of the token to delete
Required
Java
1
//Delete a token
2
TokenDeleteTransaction transaction = new TokenDeleteTransaction()
3
.setTokenId(newTokenId);
4
5
//Build the unsigned transaction, sign with the admin private key of the account, submit the transaction to a Hedera network
6
TransactionId transactionId = transaction.build(client).sign(adminKey).execute(client);
7
8
//Request the receipt of the transaction
9
TransactionReceipt getReceipt = transactionId.getReceipt(client);
10
11
//Obtain the transaction consensus status
12
Status transactionStatus = getReceipt.status;
13
14
System.out.println("The transaction consensus status is " +transactionStatus);
15
//Version: 1.2.2
Copied!
JavaScript
1
//Delete a token
2
const transaction = new TokenDeleteTransaction()
3
.setTokenId(newTokenId);
4
5
//Build the unsigned transaction, sign with admin private key of the token, submit the transaction to a Hedera network
6
const transactionId = await transaction.build(client).sign(adminKey).execute(client);
7
8
//Request the receipt of the transaction
9
const getReceipt = await transactionId.getReceipt(client);
10
11
//Obtain the transaction consensus status
12
const transactionStatus = getReceipt.status;
13
14
console.log("The transaction consensus status is " +transactionStatus);
15
//Version 1.4.2
Copied!
Last modified 1mo ago
Copy link
Contents
Methods