Class FeeEstimateQuery

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

public class FeeEstimateQuery extends Object
Query the mirror node for fee estimates for a transaction.

This query allows users, SDKs, and tools to estimate expected fees without submitting transactions to the network.

  • Constructor Details

    • FeeEstimateQuery

      public FeeEstimateQuery()
      Constructor.
  • Method Details

    • getMode

      @Nullable public FeeEstimateMode getMode()
      Extract the fee estimate mode.
      Returns:
      the fee estimate mode that was set, or null if not set
    • setMode

      public FeeEstimateQuery setMode(FeeEstimateMode mode)
      Set the mode for fee estimation.

      Defaults to FeeEstimateMode.INTRINSIC if not set.

      Parameters:
      mode - the fee estimate mode
      Returns:
      this
    • getHighVolumeThrottle

      public int getHighVolumeThrottle()
      Extract the high-volume throttle utilization in basis points.
      Returns:
      the high-volume throttle value (0–10000)
    • setHighVolumeThrottle

      public FeeEstimateQuery setHighVolumeThrottle(int highVolumeThrottle)
      Set the high-volume throttle utilization in basis points (0–10000, where 10000 = 100%).

      When non-zero, the mirror node returns a high-volume pricing multiplier in the response.

      Parameters:
      highVolumeThrottle - the throttle utilization in basis points
      Returns:
      this
    • getTransaction

      @Nullable public Transaction getTransaction()
      Extract the transaction to estimate fees for.
      Returns:
      the transaction that was set, or null if not set
    • setTransaction

      public FeeEstimateQuery setTransaction(Transaction transaction)
      Set the transaction to estimate fees for.

      This should be the raw HAPI transaction that will be estimated.

      Parameters:
      transaction - the transaction proto
      Returns:
      this
    • setTransaction

      public <T extends Transaction<T>> FeeEstimateQuery setTransaction(Transaction<T> transaction)
      Set the transaction to estimate fees for from a Transaction object.
      Parameters:
      transaction - the transaction to estimate
      Returns:
      this
    • getMaxAttempts

      public int getMaxAttempts()
      Extract the maximum number of attempts.
      Returns:
      the maximum number of attempts
    • setMaxAttempts

      public FeeEstimateQuery setMaxAttempts(int maxAttempts)
      Set the maximum number of attempts for the query.
      Parameters:
      maxAttempts - the maximum number of attempts
      Returns:
      this
    • getMaxBackoff

      public Duration getMaxBackoff()
      Extract the maximum backoff duration.
      Returns:
      the maximum backoff duration
    • setMaxBackoff

      public FeeEstimateQuery setMaxBackoff(Duration maxBackoff)
      Set the maximum backoff duration for retry attempts.
      Parameters:
      maxBackoff - the maximum backoff duration
      Returns:
      this
    • execute

      Execute the query with preset timeout.
      Parameters:
      client - the client object
      Returns:
      the fee estimate response
      Throws:
      IOException - if an I/O error occurs
      InterruptedException - if the operation is interrupted
    • execute

      public FeeEstimateResponse execute(Client client, Duration timeout) throws IOException, InterruptedException
      Execute the query with user supplied timeout.
      Parameters:
      client - the client object
      timeout - the user supplied timeout
      Returns:
      the fee estimate response
      Throws:
      IOException - if an I/O error occurs
      InterruptedException - if the operation is interrupted
    • executeAsync

      public CompletableFuture<FeeEstimateResponse> executeAsync(Client client)
      Execute the query with preset timeout asynchronously.
      Parameters:
      client - the client object
      Returns:
      the fee estimate response
    • executeAsync

      public CompletableFuture<FeeEstimateResponse> executeAsync(Client client, Duration timeout)
      Execute the query with user supplied timeout asynchronously.
      Parameters:
      client - the client object
      timeout - the user supplied timeout
      Returns:
      the fee estimate response
    • executeAsync

      void executeAsync(Client client, Duration timeout, FeeEstimateMode resolvedMode, CompletableFuture<FeeEstimateResponse> returnFuture, int attempt)
      Execute the query asynchronously (internal implementation).
      Parameters:
      client - the client object
      returnFuture - the future to complete with the result
      attempt - the current attempt number
    • buildRequest

      HttpRequest buildRequest(Client client, Duration timeout, FeeEstimateMode resolvedMode)
      Build the FeeEstimateQuery protobuf message.
      Returns:
      the protobuf query