Hedera
Search…
Delete a topic
A transaction that deletes a topic from the Hedera network. Once a topic is deleted, the topic cannot be recovered to receive messages and all submitMessage calls will fail. Older messages can still be accessed, even after the topic is deleted, via the mirror node.
Transaction Signing Requirements
  • If the adminKey was set upon the creation of the topic, the adminKey is required to sign to successfully delete the topic
  • If no adminKey was set upon the creating of the topic, you cannot delete the topic and will receive an UNAUTHORIZED error
V2
V1
Constructor
Description
new TopicDeleteTransaction()
Initializes a TopicDeleteTransaction object
1
new TopicDeleteTransaction()
Copied!

Methods

Method
Type
Description
Requirement
setTopicId(<topicId>)
TopicId
The ID of the topic to delete
Required
Java
1
//Create the transaction
2
TopicDeleteTransaction transaction = new TopicDeleteTransaction()
3
.setTopicId(newTopicId);
4
5
//Sign the transaction with the admin key, sign with the client operator and submit the transaction to a Hedera network, get the transaction ID
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
//Get the transaction consensus status
12
Status transactionStatus = receipt.status;
13
​
14
System.out.println("The transaction consensus status is " +transactionStatus);
15
​
16
//V2.0.0
Copied!
JavaScript
1
//Create the transaction
2
const transaction = await new TopicDeleteTransaction()
3
.setTopicId(newTopicId)
4
.freezeWith(client);
5
6
//Sign the transaction with the admin key
7
const signTx = await transaction.sign(adminKey);
8
9
//Sign with the client operator private key and submit 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 is " +transactionStatus);
19
​
20
//v2.0.5
Copied!
Go
1
//Create the transaction and freeze the transaction to prepare for signing
2
transaction := hedera.NewTopicDeleteTransaction().
3
SetTopicID(topicID).
4
FreezeWith(client)
5
6
​
7
//Sign the transaction with the admin key, sign with the client operator and submit the transaction to a Hedera network, get the transaction ID
8
txResponse, err := transaction.Sign(adminKey).Execute(client)
9
if err != nil {
10
panic(err)
11
}
12
​
13
//Request the receipt of the transaction
14
receipt, err = txResponse.GetReceipt(client)
15
if err != nil {
16
panic(err)
17
}
18
​
19
//Get the transaction consensus status
20
transactionStatus := receipt.Status
21
​
22
fmt.Printf("The transaction consensus status is %v\n", transactionStatus)
23
​
24
//v2.0.0
Copied!
​
Constructor
Description
new ConsensusTopicDeleteTransaction()
Initializes a ConsensusTopicDeleteTransaction object
1
new ConsensusTopicDeleteTransaction()
Copied!

Methods

Method
Type
Description
setTopicId(<topicId>)
TopicId
The ID of the topic to delete
Java
1
ConsensusTopicDeleteTransaction transaction = new ConsensusTopicDeleteTransaction()
2
.setTopicId(newTopicId);
3
​
4
//Sign the transaction with the admin key, sign with the client operator and submit the transaction to a Hedera network, get the transaction ID
5
TransactionId txId = transaction.build(client).sign(adminKey).execute(client);
6
​
7
//Request the receipt of the transaction
8
TransactionReceipt receipt = txId.getReceipt(client);
9
​
10
//Get the transaction consensus status
11
Status transactionStatus = receipt.status;
12
​
13
System.out.println("The transaction consensus status is " +transactionStatus);
14
​
15
//v1.3.2
Copied!
JavaScript
1
const transaction = new ConsensusTopicDeleteTransaction()
2
.setTopicId(newTopicId);
3
​
4
//Sign the transaction with the admin key, sign with the client operator and submit the transaction to a Hedera network, get the transaction ID
5
const txId = await transaction.build(client).sign(adminKey).execute(client);
6
​
7
//Request the receipt of the transaction
8
const receipt = await txId.getReceipt(client);
9
​
10
//Get the transaction consensus status
11
const transactionStatus = receipt.status;
12
​
13
console.log("The transaction consensus status is " +transactionStatus);
14
​
15
//v1.4.4
Copied!

Get transaction values

V2
Method
Type
Description
Requirement
getTopicId(<topicId>)
TopicId
The ID of the topic to delete
Required
Java
1
//Create the transaction
2
TopicDeleteTransaction transaction = new TopicDeleteTransaction()
3
.setTopicId(newTopicId);
4
​
5
//Get topic ID
6
TopicId getTopicId = transaction.getTopicId();
7
​
8
//v2.0.0
Copied!
JavaScript
1
//Create the transaction
2
const transaction = new TopicDeleteTransaction()
3
.setTopicId(newTopicId);
4
​
5
//Get topic ID
6
const getTopicId = transaction.getTopicId();
7
​
8
//v2.0.0
Copied!
Go
1
//Create the transaction
2
transaction := hedera.NewTopicDeleteTransaction().
3
SetTopicID(topicID)
4
​
5
//Get topic ID
6
getTopicId := transaction.GetTopicID()
7
​
8
//v2.0.0
Copied!

​

Last modified 3mo ago
Copy link