Class TopicCreateTransaction
If an autoRenewAccount is specified, that account must also sign this transaction.
If an adminKey is specified, the adminKey must sign the transaction.
On success, the resulting TransactionReceipt contains the newly created TopicId. See Hedera Documentation See Hedera Documentation
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
Indicates if the request has been attempted to be sent to all nodesprotected Duration
The timeout for each execution attemptprotected Logger
protected Integer
The maximum times execution will be attemptedprotected Duration
The maximum amount of time to wait between retriesprotected Duration
The minimum amount of time to wait between retriesprotected com.hedera.hashgraph.sdk.LockableList<AccountId>
List of account IDs for nodes with which execution will be attempted.protected com.hedera.hashgraph.sdk.LockableList<com.hedera.hashgraph.sdk.Node>
List of healthy and unhealthy nodes with which execution will be attempted.protected static final Random
Fields inherited from class com.hedera.hashgraph.sdk.Transaction
defaultMaxTransactionFee, DUMMY_ACCOUNT_ID, DUMMY_TRANSACTION_ID, frozenBodyBuilder, innerSignedTransactions, outerTransactions, publicKeys, regenerateTransactionId, signers, sigPairLists, sourceTransactionBody, transactionIds
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionExecute this transaction or queryExecute this transaction or query with a timeoutexecuteAsync
(Client client) Execute this transaction or query asynchronously.executeAsync
(Client client, Duration timeout) Execute this transaction or query asynchronously.void
executeAsync
(Client client, Duration timeout, BiConsumer<TransactionResponse, Throwable> callback) Execute this transaction or query asynchronously.void
executeAsync
(Client client, Duration timeout, Consumer<TransactionResponse> onSuccess, Consumer<Throwable> onFailure) Execute this transaction or query asynchronously.void
executeAsync
(Client client, BiConsumer<TransactionResponse, Throwable> callback) Execute this transaction or query asynchronously.void
executeAsync
(Client client, Consumer<TransactionResponse> onSuccess, Consumer<Throwable> onFailure) Execute this transaction or query asynchronously.Extract the admin key.Extract the auto renew account id.Extract the auto renew period.final int
Get the maximum times execution will be attempted.final Duration
The maximum amount of time to wait between retriesfinal int
Deprecated.final Duration
The minimum amount of time to wait between retriesGet the list of account IDs for nodes with which execution will be attempted.Extract the submit key.Extract the topic memo.final Duration
When execution is attempted, a single attempt will time out when this deadline is reached.protected void
logTransaction
(TransactionId transactionId, Client client, com.hedera.hashgraph.sdk.Node node, boolean isAsync, int attempt, TransactionResponse response, Throwable error) Logs the transaction's parameterssetAdminKey
(Key adminKey) Set the admin key for the new topic.setAutoRenewAccountId
(AccountId autoRenewAccountId) Set the ID of the auto renew account for the new topic.setAutoRenewPeriod
(Duration autoRenewPeriod) Set the auto renew period for the new topic.final TopicCreateTransaction
setGrpcDeadline
(Duration grpcDeadline) When execution is attempted, a single attempt will timeout when this deadline is reached.Set the loggerfinal TopicCreateTransaction
setMaxAttempts
(int maxAttempts) Set the maximum times execution will be attempted.final TopicCreateTransaction
setMaxBackoff
(Duration maxBackoff) The maximum amount of time to wait between retries.final TopicCreateTransaction
setMaxRetry
(int count) Deprecated.UsesetMaxAttempts(int)
instead.final TopicCreateTransaction
setMinBackoff
(Duration minBackoff) The minimum amount of time to wait between retries.final TopicCreateTransaction
setRequestListener
(UnaryOperator<Transaction> requestListener) Set a callback that will be called right before the request is sent.final TopicCreateTransaction
setResponseListener
(UnaryOperator<TransactionResponse> responseListener) Set a callback that will be called right before the response is returned.setSubmitKey
(Key submitKey) Set the submit key for the new topic.setTopicMemo
(String memo) Set a short publicly visible memo on the new topic.Methods inherited from class com.hedera.hashgraph.sdk.Transaction
addSignature, doSchedule, freeze, freezeWith, fromBytes, fromScheduledTransaction, getDefaultMaxTransactionFee, getMaxTransactionFee, getRegenerateTransactionId, getSignatures, getSignaturesAtOffset, getTransactionHash, getTransactionHashPerNode, getTransactionId, getTransactionMemo, getTransactionValidDuration, isFrozen, keyAlreadySigned, requireNotFrozen, requireOneNodeAccountId, schedule, setMaxTransactionFee, setNodeAccountIds, setRegenerateTransactionId, setTransactionId, setTransactionMemo, setTransactionValidDuration, sign, signWith, signWithOperator, spawnBodyBuilder, toBytes, toString
-
Field Details
-
random
-
maxAttempts
The maximum times execution will be attempted -
maxBackoff
The maximum amount of time to wait between retries -
minBackoff
The minimum amount of time to wait between retries -
nodeAccountIds
List of account IDs for nodes with which execution will be attempted. -
nodes
protected com.hedera.hashgraph.sdk.LockableList<com.hedera.hashgraph.sdk.Node> nodesList of healthy and unhealthy nodes with which execution will be attempted. -
attemptedAllNodes
protected boolean attemptedAllNodesIndicates if the request has been attempted to be sent to all nodes -
grpcDeadline
The timeout for each execution attempt -
logger
-
-
Constructor Details
-
TopicCreateTransaction
public TopicCreateTransaction()Constructor.
-
-
Method Details
-
getTopicMemo
Extract the topic memo.- Returns:
- the topic memo
-
setTopicMemo
Set a short publicly visible memo on the new topic.- Parameters:
memo
- The memo to be set- Returns:
this
-
getAdminKey
Extract the admin key.- Returns:
- the admin key
-
setAdminKey
Set the admin key for the new topic.Access control for updateTopic/deleteTopic.
Anyone can increase the topic's expirationTime regardless of the adminKey. If no adminKey is specified, updateTopic may only be used to extend the topic's expirationTime, and deleteTopic is disallowed.
- Parameters:
adminKey
- The Key to be set- Returns:
this
-
getSubmitKey
Extract the submit key.- Returns:
- the submit key
-
setSubmitKey
Set the submit key for the new topic.Access control for submitMessage. If unspecified, no access control is performed on ConsensusService.submitMessage (all submissions are allowed).
- Parameters:
submitKey
- The Key to be set- Returns:
this
-
getAutoRenewPeriod
Extract the auto renew period.- Returns:
- the auto renew period
-
setAutoRenewPeriod
Set the auto renew period for the new topic.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).
- Parameters:
autoRenewPeriod
- The Duration to be set for auto renewal- Returns:
this
-
getAutoRenewAccountId
Extract the auto renew account id.- Returns:
- the auto renew account id
-
setAutoRenewAccountId
Set the ID of the auto renew account for the new topic.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.
- Parameters:
autoRenewAccountId
- The AccountId to be set for auto renewal- Returns:
this
-
grpcDeadline
When execution is attempted, a single attempt will time out when this deadline is reached. (The SDK may subsequently retry the execution.)- Returns:
- The timeout for each execution attempt
-
setGrpcDeadline
When execution is attempted, a single attempt will timeout when this deadline is reached. (The SDK may subsequently retry the execution.)- Parameters:
grpcDeadline
- The timeout for each execution attempt- Returns:
this
-
getMaxBackoff
The maximum amount of time to wait between retries- Returns:
- maxBackoff
-
setMaxBackoff
The maximum amount of time to wait between retries. Every retry attempt will increase the wait time exponentially until it reaches this time.- Parameters:
maxBackoff
- The maximum amount of time to wait between retries- Returns:
this
-
getMinBackoff
The minimum amount of time to wait between retries- Returns:
- minBackoff
-
setMinBackoff
The minimum amount of time to wait between retries. When retrying, the delay will start at this time and increase exponentially until it reaches the maxBackoff.- Parameters:
minBackoff
- The minimum amount of time to wait between retries- Returns:
this
-
getMaxRetry
Deprecated.UsegetMaxAttempts()
instead.- Returns:
- Number of errors before execution will fail.
-
setMaxRetry
Deprecated.UsesetMaxAttempts(int)
instead.- Parameters:
count
- Number of errors before execution will fail- Returns:
this
-
getMaxAttempts
public final int getMaxAttempts()Get the maximum times execution will be attempted.- Returns:
- Number of errors before execution will fail.
-
setMaxAttempts
Set the maximum times execution will be attempted.- Parameters:
maxAttempts
- Execution will fail after this many errors.- Returns:
this
-
getNodeAccountIds
Get the list of account IDs for nodes with which execution will be attempted.- Returns:
- the list of account IDs
-
setRequestListener
Set a callback that will be called right before the request is sent. As input, the callback will receive the protobuf of the request, and the callback should return the request protobuf. This means the callback has an opportunity to read, copy, or modify the request that will be sent.- Parameters:
requestListener
- The callback to use- Returns:
this
-
setResponseListener
public final TopicCreateTransaction setResponseListener(UnaryOperator<TransactionResponse> responseListener) Set a callback that will be called right before the response is returned. As input, the callback will receive the protobuf of the response, and the callback should return the response protobuf. This means the callback has an opportunity to read, copy, or modify the response that will be read.- Parameters:
responseListener
- The callback to use- Returns:
this
-
setLogger
Set the logger- Parameters:
logger
- the new logger- Returns:
this
-
execute
Execute this transaction or query- Parameters:
client
- The client with which this will be executed.- Returns:
- Result of execution
- Throws:
TimeoutException
- when the transaction times outPrecheckStatusException
- when the precheck fails
-
execute
public TransactionResponse execute(Client client, Duration timeout) throws TimeoutException, PrecheckStatusException Execute this transaction or query with a timeout- Parameters:
client
- The client with which this will be executed.timeout
- The timeout after which the execution attempt will be cancelled.- Returns:
- Result of execution
- Throws:
TimeoutException
- when the transaction times outPrecheckStatusException
- when the precheck fails
-
executeAsync
Execute this transaction or query asynchronously.- Parameters:
client
- The client with which this will be executed.- Returns:
- Future result of execution
-
executeAsync
Execute this transaction or query asynchronously.- Parameters:
client
- The client with which this will be executed.timeout
- The timeout after which the execution attempt will be cancelled.- Returns:
- Future result of execution
-
executeAsync
Execute this transaction or query asynchronously.- Parameters:
client
- The client with which this will be executed.callback
- a BiConsumer which handles the result or error.
-
executeAsync
public void executeAsync(Client client, Duration timeout, BiConsumer<TransactionResponse, Throwable> callback) Execute this transaction or query asynchronously.- Parameters:
client
- The client with which this will be executed.timeout
- The timeout after which the execution attempt will be cancelled.callback
- a BiConsumer which handles the result or error.
-
executeAsync
public void executeAsync(Client client, Consumer<TransactionResponse> onSuccess, Consumer<Throwable> onFailure) Execute this transaction or query asynchronously.- Parameters:
client
- The client with which this will be executed.onSuccess
- a Consumer which consumes the result on success.onFailure
- a Consumer which consumes the error on failure.
-
executeAsync
public void executeAsync(Client client, Duration timeout, Consumer<TransactionResponse> onSuccess, Consumer<Throwable> onFailure) Execute this transaction or query asynchronously.- Parameters:
client
- The client with which this will be executed.timeout
- The timeout after which the execution attempt will be cancelled.onSuccess
- a Consumer which consumes the result on success.onFailure
- a Consumer which consumes the error on failure.
-
logTransaction
protected void logTransaction(TransactionId transactionId, Client client, com.hedera.hashgraph.sdk.Node node, boolean isAsync, int attempt, @Nullable TransactionResponse response, @Nullable Throwable error) Logs the transaction's parameters- Parameters:
transactionId
- the transaction's idclient
- the client that executed the transactionnode
- the node the transaction was sent toisAsync
- whether the transaction was executed asynchronouslyattempt
- the attempt numberresponse
- the transaction response if the transaction was successfulerror
- the error if the transaction was not successful
-
getMaxAttempts()
instead.