Class TransactionResponse

java.lang.Object
com.hedera.hashgraph.sdk.TransactionResponse

public final class TransactionResponse extends Object
When the client sends the node a transaction of any kind, the node replies with this, which simply says that the transaction passed the pre-check (so the node will submit it to the network) or it failed (so it won't). To learn the consensus result, the client should later obtain a receipt (free), or can buy a more detailed record (not free).
See Hedera Documentation
  • Field Details

    • nodeId

      public final AccountId nodeId
      The node ID
    • transactionHash

      public final byte[] transactionHash
      The transaction hash
    • transactionId

      public final TransactionId transactionId
      The transaction ID
    • scheduledTransactionId

      @Nullable @Deprecated public final TransactionId scheduledTransactionId
      Deprecated.
      The scheduled transaction ID
  • Constructor Details

    • TransactionResponse

      TransactionResponse(AccountId nodeId, TransactionId transactionId, byte[] transactionHash, @Nullable TransactionId scheduledTransactionId, Transaction transaction)
      Constructor.
      Parameters:
      nodeId - the node id
      transactionId - the transaction id
      transactionHash - the transaction hash
      scheduledTransactionId - the scheduled transaction id
  • Method Details

    • getValidateStatus

      public boolean getValidateStatus()
      Returns:
      whether getReceipt() or getRecord() will throw an exception if the receipt status is not SUCCESS
    • setValidateStatus

      public TransactionResponse setValidateStatus(boolean validateStatus)
      Parameters:
      validateStatus - whether getReceipt() or getRecord() will throw an exception if the receipt status is not SUCCESS
      Returns:
      this
    • getReceipt

      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 out
      PrecheckStatusException - when the precheck fails
      ReceiptStatusException - when there is an issue with the receipt
    • getReceipt

      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 out
      PrecheckStatusException - when the precheck fails
      ReceiptStatusException - when there is an issue with the receipt
    • getReceiptQuery

      public TransactionReceiptQuery getReceiptQuery()
      Create receipt query from the transactionId and transactionHash
      Returns:
      TransactionReceiptQuery
    • getReceiptQuery

      public TransactionReceiptQuery getReceiptQuery(Client client)
      Create receipt query from the transactionId and transactionHash
      Returns:
      TransactionReceiptQuery
    • getReceiptAsync

      public CompletableFuture<TransactionReceipt> getReceiptAsync(Client client)
      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

      public CompletableFuture<TransactionReceipt> getReceiptAsync(Client client, Duration timeout)
      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

      public void getReceiptAsync(Client client, BiConsumer<TransactionReceipt,Throwable> callback)
      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

      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 out
      PrecheckStatusException - when the precheck fails
      ReceiptStatusException - when there is an issue with the receipt
    • getRecord

      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 out
      PrecheckStatusException - when the precheck fails
      ReceiptStatusException - when there is an issue with the receipt
    • getRecordQuery

      public TransactionRecordQuery getRecordQuery()
      Create record query from the transactionId and transactionHash
      Returns:
      TransactionRecordQuery
    • getRecordQuery

      public TransactionRecordQuery getRecordQuery(Client client)
      Create record query from the transactionId and transactionHash
      Returns:
      TransactionRecordQuery
    • getRecordAsync

      public CompletableFuture<TransactionRecord> getRecordAsync(Client client)
      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

      public CompletableFuture<TransactionRecord> getRecordAsync(Client client, Duration timeout)
      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

      public void getRecordAsync(Client client, BiConsumer<TransactionRecord,Throwable> callback)
      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.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toJsonObject

      com.google.gson.JsonObject toJsonObject()
      Build a JSON representation of this response
      Returns:
      the JSON object
    • toJson

      public String toJson()
      Serialize this response to a JSON string, matching the JS SDK's JSON.stringify(response.toJSON()) so all SDKs produce identical JSON.
      Returns:
      the JSON string