Class TopicCreateTransaction


public final class TopicCreateTransaction extends Transaction<TopicCreateTransaction>
Create a topic to accept and group consensus messages. If `autoRenewAccount` is specified, that account Key MUST also sign this transaction.
If `adminKey` is set, that Key MUST sign the transaction.
On success, the resulting `TransactionReceipt` SHALL contain the newly created `TopicId`. The `autoRenewPeriod` on a topic MUST be set to a value between `autoRenewPeriod.minDuration` and `autoRenewPeriod.maxDuration`. These values are configurable, typically 30 and 92 days.
This also sets the initial expirationTime of the topic. If no `adminKey` is set on a topic -`autoRenewAccount` SHALL NOT be set on the topic. - A `deleteTopic` transaction SHALL fail. - An `updateTopic` transaction that only extends the expirationTime MAY succeed. - Any other `updateTopic` transaction SHALL fail. If the topic expires and is not automatically renewed, the topic SHALL enter the `EXPIRED` state. - All transactions on the topic SHALL fail with TOPIC_EXPIRED - Except an updateTopic() call that only extends the expirationTime. - getTopicInfo() SHALL succeed, and show the topic is expired. The topic SHALL remain in the `EXPIRED` state for a time determined by the `autorenew.gracePeriod` (configurable, originally 7 days).
After the grace period, if the topic's expirationTime is not extended, the topic SHALL be automatically deleted from state entirely, and cannot be recovered or recreated. ### Block Stream Effects None
  • Constructor Details

    • TopicCreateTransaction

      public TopicCreateTransaction()
      Constructor.
    • TopicCreateTransaction

      TopicCreateTransaction(LinkedHashMap<TransactionId,LinkedHashMap<AccountId,Transaction>> txs) throws com.google.protobuf.InvalidProtocolBufferException
      Constructor.
      Parameters:
      txs - Compound list of transaction id's list of (AccountId, Transaction) records
      Throws:
      com.google.protobuf.InvalidProtocolBufferException - when there is an issue with the protobuf
    • TopicCreateTransaction

      TopicCreateTransaction(TransactionBody txBody)
      Constructor.
      Parameters:
      txBody - protobuf TransactionBody
  • Method Details

    • getTopicMemo

      public String getTopicMemo()
      Extract the topic memo.
      Returns:
      the topic memo
    • setTopicMemo

      public TopicCreateTransaction setTopicMemo(String memo)
      Set a short publicly visible memo on the new topic.
      Parameters:
      memo - The memo to be set
      Returns:
      this
    • getAdminKey

      @Nullable public Key getAdminKey()
      Extract the admin key.
      Returns:
      the admin key
    • setAdminKey

      public TopicCreateTransaction setAdminKey(Key adminKey)
      Access control for modification of the topic after it is created.

      If this field is set, that key MUST sign this transaction.
      If this field is set, that key MUST sign each future transaction to update or delete the topic.
      An updateTopic transaction that _only_ extends the topic expirationTime (a "manual renewal" transaction) SHALL NOT require admin key signature.
      A topic without an admin key SHALL be immutable, except for expiration and renewal.
      If adminKey is not set, then `autoRenewAccount` SHALL NOT be set.

      Parameters:
      adminKey - The Key to be set
      Returns:
      this
    • getSubmitKey

      @Nullable public Key getSubmitKey()
      Extract the submit key.
      Returns:
      the submit key
    • setSubmitKey

      public TopicCreateTransaction setSubmitKey(Key submitKey)
      Access control for message submission to the topic.

      If this field is set, that key MUST sign each consensus submit message for this topic.
      If this field is not set then any account may submit a message on the topic, without restriction.

      Parameters:
      submitKey - The Key to be set
      Returns:
      this
    • getAutoRenewPeriod

      @Nullable public Duration getAutoRenewPeriod()
      Extract the auto renew period.
      Returns:
      the auto renew period
    • setAutoRenewPeriod

      public TopicCreateTransaction setAutoRenewPeriod(Duration autoRenewPeriod)
      The initial lifetime, in seconds, for the topic.
      This is also the number of seconds for which the topic SHALL be automatically renewed upon expiring, if it has a valid auto-renew account.

      This value MUST be set.
      This value MUST be greater than the configured MIN_AUTORENEW_PERIOD.
      This value MUST be less than the configured MAX_AUTORENEW_PERIOD.

      Parameters:
      autoRenewPeriod - The Duration to be set for auto renewal
      Returns:
      this
    • getAutoRenewAccountId

      @Nullable public AccountId getAutoRenewAccountId()
      Extract the auto renew account id.
      Returns:
      the auto renew account id
    • setAutoRenewAccountId

      public TopicCreateTransaction setAutoRenewAccountId(AccountId autoRenewAccountId)
      The ID of the account to be charged renewal fees at the topic's expirationTime to extend the lifetime of the topic.

      The topic lifetime SHALL be extended by the smallest of the following:

      • The current `autoRenewPeriod` duration.
      • The maximum duration that this account has funds to purchase.
      • The configured MAX_AUTORENEW_PERIOD at the time of automatic renewal.
      If this value is set, the referenced account MUST sign this transaction.
      If this value is set, the `adminKey` field MUST also be set (though that key MAY not have any correlation to this account).
      Parameters:
      autoRenewAccountId - The AccountId to be set for auto renewal
      Returns:
      this
    • getFeeScheduleKey

      public Key getFeeScheduleKey()
      Returns the key which allows updates to the new topic’s fees.
      Returns:
      the feeScheduleKey
    • setFeeScheduleKey

      public TopicCreateTransaction setFeeScheduleKey(Key feeScheduleKey)
      Sets the key which allows updates to the new topic’s fees.
      Parameters:
      feeScheduleKey - the feeScheduleKey to be set
      Returns:
      this
    • getFeeExemptKeys

      public List<Key> getFeeExemptKeys()
      Returns the keys that will be exempt from paying fees.
      Returns:
      the feeExemptKeys
    • setFeeExemptKeys

      public TopicCreateTransaction setFeeExemptKeys(List<Key> feeExemptKeys)
      Sets the keys that will be exempt from paying fees.
      Parameters:
      feeExemptKeys - the keys to be set
      Returns:
      this
    • clearFeeExemptKeys

      public TopicCreateTransaction clearFeeExemptKeys()
      Clears all keys that will be exempt from paying fees.
      Returns:
      this
    • addFeeExemptKey

      public TopicCreateTransaction addFeeExemptKey(Key feeExemptKey)
      Adds a key that will be exempt from paying fees.
      Parameters:
      feeExemptKey - feeExemptKey
      Returns:
      this
    • getCustomFees

      public List<CustomFixedFee> getCustomFees()
      Returns the fixed fees to assess when a message is submitted to the new topic.
      Returns:
      the List
    • setCustomFees

      public TopicCreateTransaction setCustomFees(List<CustomFixedFee> customFees)
      Sets the fixed fees to assess when a message is submitted to the new topic.
      Parameters:
      customFees - List of CustomFixedFee
      Returns:
      this
    • clearCustomFees

      public TopicCreateTransaction clearCustomFees()
      Clears fixed fees.
      Returns:
      this
    • addCustomFee

      public TopicCreateTransaction addCustomFee(CustomFixedFee customFixedFee)
      Adds fixed fee to assess when a message is submitted to the new topic.
      Parameters:
      customFixedFee - CustomFixedFee
      Returns:
      this
    • initFromTransactionBody

      void initFromTransactionBody()
      Initialize from the transaction body.
    • build

      Build the transaction body.
      Returns:
      ConsensusCreateTopicTransactionBody
    • validateChecksums

      void validateChecksums(Client client) throws BadEntityIdException
      Specified by:
      validateChecksums in class Transaction<TopicCreateTransaction>
      Throws:
      BadEntityIdException
    • getMethodDescriptor

      io.grpc.MethodDescriptor<Transaction,TransactionResponse> getMethodDescriptor()
      Description copied from class: Executable
      Called to direct the invocation of the query to the appropriate gRPC service.
      Specified by:
      getMethodDescriptor in class Executable<TopicCreateTransaction,Transaction,TransactionResponse,TransactionResponse>
    • onFreeze

      void onFreeze(TransactionBody.Builder bodyBuilder)
      Description copied from class: Transaction
      Called in Transaction.freezeWith(Client) just before the transaction body is built. The intent is for the derived class to assign their data variant to the transaction body.
      Specified by:
      onFreeze in class Transaction<TopicCreateTransaction>
    • onScheduled

      void onScheduled(SchedulableTransactionBody.Builder scheduled)
      Description copied from class: Transaction
      Called in Transaction.schedule() when converting transaction into a scheduled version.
      Specified by:
      onScheduled in class Transaction<TopicCreateTransaction>
    • freezeWith

      public TopicCreateTransaction freezeWith(@Nullable Client client)
      Description copied from class: Transaction
      Freeze this transaction from further modification to prepare for signing or serialization.

      Will use the `Client`, if available, to generate a default Transaction ID and select 1/3 nodes to prepare this transaction for.

      Overrides:
      freezeWith in class Transaction<TopicCreateTransaction>
      Parameters:
      client - the configured client
      Returns:
      this