Skip to content

Latest commit

 

History

History
162 lines (121 loc) · 8.73 KB

update-a-topic.md

File metadata and controls

162 lines (121 loc) · 8.73 KB

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. Currently, rent is not enforced for topics so auto-renew payments will not be made.
Auto Renew Period

Set a new auto-renew period for this topic. Currently, rent is not enforced for topics so auto-renew payments will not be made.

NOTE: The minimum period of time is approximately 30 days (2592000 seconds) and the maximum period of time is approximately 92 days (8000001 seconds). Any other value outside of this range will return the following error: AUTORENEW_DURATION_NOT_IN_RANGE.

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.

Transaction Fees

  • Please see the transaction and query fees table for the base transaction fee.
  • Please use the Hedera fee estimator to estimate your transaction fee cost.

Methods

MethodTypeRequirements
setTopicId(<topicId>)TopicIdRequired
setAdminKey(<adminKey>)KeyOptional
setSubmitKey(<submitKey>)KeyOptional
setExpirationTime(<expirationTime>)InstantOptional
setTopicMemo(<memo>)StringOptional
setAutoRenewAccountId(<accountId>)AccountIdOptional
setAutoRenewPeriod(<autoRenewPeriod>)DurationOptional
clearAdminKey()Optional
clearSubmitKey()Optional
clearTopicMemo()Optional
clearAutoRenewAccountId()Optional

{% tabs %} {% tab title="Java" %}

 //Create a transaction to add a submit key
TopicUpdateTransaction transaction = new TopicUpdateTransaction()
    .setTopicId(topicId)
    .setSubmitKey(submitKey);

//Sign the transaction with the admin key to authorize the update
TopicUpdateTransaction signTx = transaction.freezeWith(client).sign(adminKey);

//Sign the transaction with the client operator, submit to a Hedera network, get the transaction ID
TransactionResponse txResponse = signTx.execute(client);

//Request the receipt of the transaction
TransactionReceipt receipt = txResponse.getReceipt(client);

//Get the transaction consensus status
Status transactionStatus = receipt.status;

System.out.println("The transaction consensus status is " +transactionStatus);

//v2.0.0

{% endtab %}

{% tab title="JavaScript" %}

//Create a transaction to add a submit key
const transaction = await new TopicUpdateTransaction()
    .setTopicId(topicId)
    .setSubmitKey(submitKey)
    .freezeWith(client);

//Sign the transaction with the admin key to authorize the update
const signTx = await transaction.sign(adminKey);
    
//Sign with the client operator private key and submit to a Hedera network
const txResponse = await signTx.execute(client);

//Request the receipt of the transaction
const receipt = await txResponse.getReceipt(client);

//Get the transaction consensus status
const transactionStatus = receipt.status;

console.log("The transaction consensus status is " +transactionStatus);

//v2.0.0

{% endtab %}

{% tab title="Go" %}

//Create the transaction
transaction := hedera.NewTopicUpdateTransaction().
		SetTopicId(topicId).
    		SetTopicMemo("new memo")

//Sign with the client operator private key and submit the transaction to a Hedera network
txResponse, err := transaction.FreezeWith(client).Sign(adminkey)Execute(client)

if err != nil {
		panic(err)
}

//Request the receipt of the transaction
receipt, err := txResponse.GetReceipt(client)

if err != nil {
		panic(err)
}

//Get the transaction consensus status
transactionStatus := receipt.Status

fmt.Printf("The transaction consensus status is %v\n", transactionStatus)
//v2.0.0

{% endtab %} {% endtabs %}

Get transaction values

Method Type Requirements
getTopicId() TopicId Required
getAdminKey() Key Optional
getSubmitKey() Key Optional
getTopicMemo() String Optional
getAutoRenewAccountId() AccountId Required
getAutoRenewPeriod() Duration Required

{% tabs %} {% tab title="Java" %}

 //Create a transaction to add a submit key
TopicUpdateTransaction transaction = new TopicUpdateTransaction()
    .setSubmitKey(submitKey);

//Get submit key
transaction.getSubmitKey()

//v2.0.0

{% endtab %}

{% tab title="JavaScript" %}

 //Create a transaction to add a submit key
const transaction = new TopicUpdateTransaction()
    .setSubmitKey(submitKey);

//Get submit key
transaction.getSubmitKey()

//v2.0.0

{% endtab %}

{% tab title="Go" %}

//Create the transaction
transaction := hedera.NewTopicUpdateTransaction()
    SetSubmitKey()

transaction := transaction.GetSubmitKey()

//v2.0.0

{% endtab %} {% endtabs %}