Skip to content

Latest commit

 

History

History
148 lines (136 loc) · 5.77 KB

update-a-topic.md

File metadata and controls

148 lines (136 loc) · 5.77 KB

Update a topic

ConsensusTopicUpdateTransaction() updates the properties of an existing topic. This includes the topic memo, admin key, submit key, and expiration time. If the adminKey was set upon the creation of the topic, the adminKey is required to sign the transaction to modify any of the topic properties.

Constructor Description
ConsensusTopicUpdateTransaction() Initializes the ConsensusTopicUpdateTransaction object
new ConsensusTopicUpdateTransaction()

Basic

The adminKey and submitKey on the topic can be updated to any of the following key structures:

  • Simple Key: one key has the authority to modify the topic (adminKey) or to submit a message to that topic (submitKey)
  • Key List: A list of keys that are all required to sign transactions to modify the properties of a topic (adminKey) or to submit a message to that topic (submitKey)
  • Threshold Keys: Requires a minimum of x number of signatures from a total of y signatures to modify the properties of a topic (adminKey) or to submit a message to that topic (submitKey)
Methods Type Description
setTopicId(<topicId>) TopicId The ID of the topic to update
setTopicMemo(<memo>) String Adds/updates the memo for a topic. No guarantee of uniqueness. Null for "do not update".
setAdminKey(<key>) PublicKey Access control for update/delete of the topic. If unspecified, no change. If empty keyList - the adminKey is cleared.
setSubmitKey(<key>) PublicKey Access control for ConsensusService.submitMessage. If unspecified, no change. If empty keyList - the submitKey is cleared.

setExpirationTime

(<expirationTime>)

Instant Effective consensus timestamp at (and after) which all consensus transactions and queries will fail. The expirationTime may be no longer than 90 days from the consensus timestamp of this transaction. If unspecified, no change.

setAutoRenewPeriod

(<autoRenewPeriod>)

Duration The initial lifetime of the topic and the amount of time to attempt to extend the topic's lifetime by automatically at the topic's expirationTime, if the autoRenewAccount is configured (once autoRenew functionality is supported by HAPI). Limited to MIN_AUTORENEW_PERIOD and MAX_AUTORENEW_PERIOD value by server-side configuration.

setAutoRenewAccountId

(<autoRenewAccountId>)

AccountId Optional account to be used at the topic's expirationTime to extend the life of the topic (once autoRenew functionality is supported by HAPI). The topic lifetime will be extended up to a maximum of the autoRenewPeriod or however long the topic can be extended using all funds on the account (whichever is the smaller duration/amount and if any extension is possible with the account's funds).If specified, there must be an adminKey and the autoRenewAccount must sign this transaction.
clearTopicMemo() Explicitly clear any memo on the topic
clearAdminKey() Explicitly clear any adminKey on the topic
clearSubmitKey() Explicitly clear any submitKey on the topic
clearAutoRenewAccountId() Explicitly clear any auto renew account ID on the topic
### Example

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

TransactionId updateTopicTx = new ConsensusTopicUpdateTransaction()
    .setTopicId(topicId)
    .setTopicMemo("Update topic memo")
    .execute(client);

{% endtab %}

{% tab title="JavaScript" %}

const updateTopicTx = await new ConsensusTopicUpdateTransaction()
    .setTopicId(topicId)
    .setTopicMemo("Update topic memo")
    .execute(client);

{% endtab %} {% endtabs %}