Hedera
Search…
Update a topic
A transaction that updates the properties of an existing topic. This includes the topic memo, admin key, submit key, auto renew account, and auto renew period.

Topic Properties

Field
Description
Topic ID
Update the topic ID
Admin Key
Set a new admin key that authorizes update topic and delete topic transactions.
Submit Key
Set a new submit key for a topic that authorizes sending messages to this topic.
Topic Memo
Set a new short publicly visible memo on the new topic and is stored with the topic. (100 bytes)
Auto Renew Account
Set a new auto-renew account ID for this topic (once autoRenew functionality is supported by HAPI).
Auto Renew Period
Set a new auto -enew period for this topic (once autoRenew functionality is supported by HAPI).
Transaction Signing Requirements
  • If an admin key is updated, the transaction must be signed by the pre-update admin key and post-update admin key.
  • If the admin key was set during the creation of the topic, the admin key must sign the transaction to update any of the topic's properties
  • If no adminKey was defined during the creation of the topic, you can only extend the expirationTime.
V2
V1
Constructor
Description
new TopicUpdateTransaction()
Initializes the TopicUpdateTransaction object
1
new TopicUpdateTransaction()
Copied!

Methods

Method
Type
Requirements
setAdminKey(<adminKey>)
Key
Optional
setSubmitKey(<submitKey>)
Key
Optional
setExpirationTime(<expirationTime>)
Instant
Optional
setTopicMemo(<memo>)
String
Optional
setAutoRenewAccountId(<accountId>)
AccountId
Optional
setAutoRenewPeriod(<autoRenewAccountId>)
Duration
Optional
clearAdminKey()
​
Optional
clearSubmitKey()
​
Optional
clearTopicMemo()
​
Optional
clearAutoRenewAccountId()
​
Optional
Java
1
//Create a transaction to add a submit key
2
TopicUpdateTransaction transaction = new TopicUpdateTransaction()
3
.setSubmitKey(submitKey);
4
​
5
//Sign the transaction with the admin key to authorize the update
6
TopicUpdateTransaction signTx = transaction.freezeWith(client).sign(adminKey);
7
​
8
//Sign the transaction with the client operator, submit to a Hedera network, get the transaction ID
9
TransactionResponse txResponse = signTx.execute(client);
10
​
11
//Request the receipt of the transaction
12
TransactionReceipt receipt = txResponse.getReceipt(client);
13
​
14
//Get the transaction consensus status
15
Status transactionStatus = receipt.status;
16
​
17
System.out.println("The transaction consensus status is " +transactionStatus);
18
​
19
//v2.0.0
Copied!
JavaScript
1
//Create a transaction to add a submit key
2
const transaction = await new TopicUpdateTransaction()
3
.setSubmitKey(submitKey
4
.freezeWith(client);
5
​
6
//Sign the transaction with the admin key to authorize the update
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.0
Copied!
Go
1
//Create the transaction
2
transaction := hedera.NewTopicUpdateTransaction()
3
SetTopicMemo("new memo)
4
​
5
//Sign with the client operator private key and submit the transaction to a Hedera network
6
txResponse, err := transaction.FreezeWith(client).Sign(adminkey)Execute(client)
7
​
8
if err != nil {
9
panic(err)
10
}
11
​
12
//Request the receipt of the transaction
13
receipt, err := txResponse.GetReceipt(client)
14
​
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
//v2.0.0
Copied!
Constructor
Description
new ConsensusTopicUpdateTransaction()
Initializes the ConsensusTopicUpdateTransaction object
1
new ConsensusTopicUpdateTransaction()
Copied!

Methods

Method
Type
Requirements
setTopicId(<topicId>)
TopicId
Required
setAdminKey(<adminKey>)
Key
Optional
setSubmitKey(<submitKey>)
Key
Optional
setExpirationTime(<expirationTime>)
Instant
Optional
setTopicMemo(<memo>)
String
Optional
setAutoRenewAccountId(<accountId>)
AccountId
Optional
setAutoRenewPeriod(<autoRenewAccountId>)
Duration
Optional
clearAdminKey()
​
Optional
clearSubmitKey()
​
Optional
clearTopicMemo()
​
Optional
clearAutoRenewAccountId()
​
Optional
Java
1
//Create a transaction to add a submit key
2
ConsensusTopicUpdateTransaction transaction = new ConsensusTopicUpdateTransaction()
3
.setSubmitKey(submitKey);
4
​
5
//Sign the transaction with the admin key to authorize the update
6
ConsensusTopicUpdateTransaction signTx = transaction.build(client).sign(adminKey);
7
​
8
//Sign the transaction with the client operator, submit to a Hedera network, get the transaction ID
9
TransactionId txId = signTx.execute(client);
10
​
11
//Request the receipt of the transaction
12
TransactionReceipt receipt = txId.getReceipt(client);
13
​
14
//Get the transaction consensus status
15
Status transactionStatus = receipt.status;
16
​
17
System.out.println("The transaction consensus status is " +transactionStatus);
18
​
19
//v1.3.2
Copied!
JavaScript
1
//Create a transaction to add a submit key
2
const transaction = await new ConsensusTopicUpdateTransaction()
3
.setSubmitKey(submitKey)
4
.build(client);
5
​
6
//Sign the transaction with the admin key to authorize the update
7
const signTx = await transaction.sign(adminKey);
8
​
9
//Sign the transaction with the client operator, submit to a Hedera network, get the transaction ID
10
const txId = await signTx.execute(client);
11
​
12
//Request the receipt of the transaction
13
const receipt = await txId.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
//v1.4.4
Copied!

Get transaction values

V2
Method
Type
Requirements
getTopicId()
TopicId
Optional
getAdminKey()
Key
Optional
getSubmitKey()
Key
Optional
getTopicMemo()
String
Optional
getAutoRenewAccountId()
AccountId
Disabled
getAutoRenewPeriod()
Duration
Disabled
Java
1
//Create a transaction to add a submit key
2
TopicUpdateTransaction transaction = new TopicUpdateTransaction()
3
.setSubmitKey(submitKey);
4
​
5
//Get submit key
6
transaction.getSubmitKey()
7
​
8
//v2.0.0
Copied!
JavaScript
1
//Create a transaction to add a submit key
2
const transaction = new TopicUpdateTransaction()
3
.setSubmitKey(submitKey);
4
​
5
//Get submit key
6
transaction.getSubmitKey()
7
​
8
//v2.0.0
Copied!
Go
1
//Create the transaction
2
transaction := hedera.NewTopicUpdateTransaction()
3
SetSubmitKey()
4
​
5
transaction := transaction.GetSubmitKey()
6
​
7
//v2.0.0
Copied!

​

Last modified 3mo ago
Copy link