java.lang.Object
com.hedera.hashgraph.sdk.TransactionId
- All Implemented Interfaces:
Comparable<TransactionId>
The client-generated ID for a transaction.
This is used for retrieving receipts and records for a transaction, for appending to a file right after creating it, for instantiating a smart contract with bytecode in a file just created, and internally by the network for detecting when duplicate transactions are submitted.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTransactionId(AccountId accountId, Instant validStart) No longer part of the public API. -
Method Summary
Modifier and TypeMethodDescriptionintbooleanstatic TransactionIdfromBytes(byte[] bytes) Create a new transaction id from a byte array.(package private) static TransactionIdfromProtobuf(TransactionID transactionID) Create a transaction id from a protobuf.static TransactionIdfromString(String s) Create a new transaction id from a string.static TransactionIdGenerates a new transaction ID for the given account ID.getNonce()Extract the nonce.getReceipt(Client client) Fetch the receipt of the transaction.getReceipt(Client client, Duration timeout) Fetch the receipt of the transaction.getReceiptAsync(Client client) Fetch the receipt of the transaction asynchronously.getReceiptAsync(Client client, Duration timeout) Fetch the receipt of the transaction asynchronously.voidgetReceiptAsync(Client client, Duration timeout, BiConsumer<TransactionReceipt, Throwable> callback) Fetch the receipt of the transaction asynchronously.voidgetReceiptAsync(Client client, Duration timeout, Consumer<TransactionReceipt> onSuccess, Consumer<Throwable> onFailure) Fetch the receipt of the transaction asynchronously.voidgetReceiptAsync(Client client, BiConsumer<TransactionReceipt, Throwable> callback) Fetch the receipt of the transaction asynchronously.voidgetReceiptAsync(Client client, Consumer<TransactionReceipt> onSuccess, Consumer<Throwable> onFailure) Fetch the receipt of the transaction asynchronously.Fetch the record of the transaction.Fetch the record of the transaction.getRecordAsync(Client client) Fetch the record of the transaction asynchronously.getRecordAsync(Client client, Duration timeout) Fetch the record of the transaction asynchronously.voidgetRecordAsync(Client client, Duration timeout, BiConsumer<TransactionRecord, Throwable> callback) Fetch the record of the transaction asynchronously.voidgetRecordAsync(Client client, Duration timeout, Consumer<TransactionRecord> onSuccess, Consumer<Throwable> onFailure) Fetch the record of the transaction asynchronously.voidgetRecordAsync(Client client, BiConsumer<TransactionRecord, Throwable> callback) Fetch the record of the transaction asynchronously.voidgetRecordAsync(Client client, Consumer<TransactionRecord> onSuccess, Consumer<Throwable> onFailure) Fetch the record of the transaction asynchronously.booleanExtract the scheduled status.inthashCode()Assign the nonce value.setScheduled(boolean scheduled) Assign the scheduled status.byte[]toBytes()Extract the byte array representation.(package private) TransactionIDExtract the transaction id protobuf.toString()toStringWithChecksum(Client client) Convert to a string representation with checksum.static TransactionIdwithValidStart(AccountId accountId, Instant validStart) Create a transaction id.
-
Field Details
-
accountId
The Account ID that paid for this transaction. -
validStart
The time from when this transaction is valid.When a transaction is submitted there is additionally a validDuration (defaults to 120s) and together they define a time window that a transaction may be processed in.
-
-
Constructor Details
-
TransactionId
No longer part of the public API. Use `Transaction.withValidStart()` instead.- Parameters:
accountId- the account idvalidStart- the valid start time
-
-
Method Details
-
withValidStart
Create a transaction id.- Parameters:
accountId- the account idvalidStart- the valid start time- Returns:
- the new transaction id
-
generate
Generates a new transaction ID for the given account ID.Note that transaction IDs are made of the valid start of the transaction and the account that will be charged the transaction fees for the transaction.
- Parameters:
accountId- the ID of the Hedera account that will be charge the transaction fees.- Returns:
TransactionId
-
fromProtobuf
Create a transaction id from a protobuf.- Parameters:
transactionID- the protobuf- Returns:
- the new transaction id
-
fromString
Create a new transaction id from a string.- Parameters:
s- the string representing the transaction id- Returns:
- the new transaction id
-
fromBytes
public static TransactionId fromBytes(byte[] bytes) throws com.google.protobuf.InvalidProtocolBufferException Create a new transaction id from a byte array.- Parameters:
bytes- the byte array- Returns:
- the new transaction id
- Throws:
com.google.protobuf.InvalidProtocolBufferException- when there is an issue with the protobuf
-
getScheduled
public boolean getScheduled()Extract the scheduled status.- Returns:
- the scheduled status
-
setScheduled
Assign the scheduled status.- Parameters:
scheduled- the scheduled status- Returns:
this
-
getNonce
Extract the nonce.- Returns:
- the nonce value
-
setNonce
Assign the nonce value.- Parameters:
nonce- the nonce value- Returns:
this
-
getReceipt
public TransactionReceipt getReceipt(Client client) throws TimeoutException, PrecheckStatusException, ReceiptStatusException Fetch the receipt of the transaction.- Parameters:
client- The client with which this will be executed.- Returns:
- the transaction receipt
- Throws:
TimeoutException- when the transaction times outPrecheckStatusException- when the precheck failsReceiptStatusException- when there is an issue with the receipt
-
getReceipt
public TransactionReceipt getReceipt(Client client, Duration timeout) throws TimeoutException, PrecheckStatusException, ReceiptStatusException Fetch the receipt of the transaction.- Parameters:
client- The client with which this will be executed.timeout- The timeout after which the execution attempt will be cancelled.- Returns:
- the transaction receipt
- Throws:
TimeoutException- when the transaction times outPrecheckStatusException- when the precheck failsReceiptStatusException- when there is an issue with the receipt
-
getReceiptAsync
Fetch the receipt of the transaction asynchronously.- Parameters:
client- The client with which this will be executed.- Returns:
- future result of the transaction receipt
-
getReceiptAsync
Fetch the receipt of the transaction asynchronously.- Parameters:
client- The client with which this will be executed.timeout- The timeout after which the execution attempt will be cancelled.- Returns:
- the transaction receipt
-
getReceiptAsync
Fetch the receipt of the transaction asynchronously.- Parameters:
client- The client with which this will be executed.callback- a BiConsumer which handles the result or error.
-
getReceiptAsync
public void getReceiptAsync(Client client, Duration timeout, BiConsumer<TransactionReceipt, Throwable> callback) Fetch the receipt of the transaction 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.
-
getReceiptAsync
public void getReceiptAsync(Client client, Consumer<TransactionReceipt> onSuccess, Consumer<Throwable> onFailure) Fetch the receipt of the transaction 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.
-
getReceiptAsync
public void getReceiptAsync(Client client, Duration timeout, Consumer<TransactionReceipt> onSuccess, Consumer<Throwable> onFailure) Fetch the receipt of the transaction 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.
-
getRecord
public TransactionRecord getRecord(Client client) throws TimeoutException, PrecheckStatusException, ReceiptStatusException Fetch the record of the transaction.- Parameters:
client- The client with which this will be executed.- Returns:
- the transaction record
- Throws:
TimeoutException- when the transaction times outPrecheckStatusException- when the precheck failsReceiptStatusException- when there is an issue with the receipt
-
getRecord
public TransactionRecord getRecord(Client client, Duration timeout) throws TimeoutException, PrecheckStatusException, ReceiptStatusException Fetch the record of the transaction.- Parameters:
client- The client with which this will be executed.timeout- The timeout after which the execution attempt will be cancelled.- Returns:
- the transaction record
- Throws:
TimeoutException- when the transaction times outPrecheckStatusException- when the precheck failsReceiptStatusException- when there is an issue with the receipt
-
getRecordAsync
Fetch the record of the transaction asynchronously.- Parameters:
client- The client with which this will be executed.- Returns:
- future result of the transaction record
-
getRecordAsync
Fetch the record of the transaction 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 the transaction record
-
getRecordAsync
Fetch the record of the transaction asynchronously.- Parameters:
client- The client with which this will be executed.callback- a BiConsumer which handles the result or error.
-
getRecordAsync
public void getRecordAsync(Client client, Duration timeout, BiConsumer<TransactionRecord, Throwable> callback) Fetch the record of the transaction 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.
-
getRecordAsync
public void getRecordAsync(Client client, Consumer<TransactionRecord> onSuccess, Consumer<Throwable> onFailure) Fetch the record of the transaction 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.
-
getRecordAsync
public void getRecordAsync(Client client, Duration timeout, Consumer<TransactionRecord> onSuccess, Consumer<Throwable> onFailure) Fetch the record of the transaction 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.
-
toProtobuf
TransactionID toProtobuf()Extract the transaction id protobuf.- Returns:
- the protobuf representation
-
toString
-
toStringWithChecksum
Convert to a string representation with checksum.- Parameters:
client- the configured client- Returns:
- the string representation with checksum
-
toBytes
public byte[] toBytes()Extract the byte array representation.- Returns:
- the byte array representation
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareToin interfaceComparable<TransactionId>
-