Skip to main content

FeeEstimateQuery

Struct FeeEstimateQuery 

Source
pub struct FeeEstimateQuery { /* private fields */ }
Expand description

Fee estimation query that communicates with the mirror node REST API.

This query estimates the expected transaction fees without submitting the transaction to the network, per HIP-1261.

§Examples

use hiero_sdk::{Client, AccountId, PrivateKey, TransferTransaction, FeeEstimateQuery, FeeEstimateMode};

let client = Client::for_testnet();
client.set_operator(AccountId::new(0, 0, 1234), PrivateKey::generate_ed25519());

let mut tx = TransferTransaction::new();
// ... configure transaction ...

let response = FeeEstimateQuery::new()
    .set_transaction(&mut tx, &client)?
    .set_mode(FeeEstimateMode::Intrinsic)
    .execute(&client)
    .await?;

println!("Estimated fee: {} tinycents", response.total);

Implementations§

Source§

impl FeeEstimateQuery

Source

pub fn new() -> Self

Creates a new fee estimate query with default settings.

Source

pub fn set_mode(self, mode: FeeEstimateMode) -> Self

Sets the fee estimation mode.

Source

pub fn get_mode(&self) -> FeeEstimateMode

Returns the fee estimation mode.

Source

pub fn set_transaction<D: TransactionExecute>( self, transaction: &mut Transaction<D>, client: &Client, ) -> Result<Self>

Sets the transaction to estimate fees for.

The transaction will be automatically frozen with the given client if not already frozen. For chunked transactions, only the first chunk is used for fee estimation.

§Errors
  • If the transaction cannot be frozen.
  • If the transaction bytes cannot be serialized.
Source

pub fn set_transaction_bytes(self, bytes: Vec<u8>) -> Self

Sets the protobuf-encoded transaction bytes to estimate fees for.

The transaction must be frozen before calling to_bytes().

Source

pub fn get_transaction_bytes(&self) -> Option<&[u8]>

Returns the transaction bytes, if set.

Source

pub fn set_high_volume_throttle(self, basis_points: u32) -> Self

Sets the high-volume throttle utilization in basis points (0–10000).

This simulates throttle utilization for high-volume pricing per HIP-1313 without impacting the actual network.

§Panics

Panics if basis_points is greater than 10000.

Source

pub fn get_high_volume_throttle(&self) -> Option<u32>

Returns the high-volume throttle, if set.

Source

pub fn set_max_attempts(self, max_attempts: usize) -> Self

Sets the maximum number of retry attempts.

Source

pub fn get_max_attempts(&self) -> usize

Returns the maximum number of retry attempts.

Source

pub fn set_max_backoff(self, max_backoff: Duration) -> Self

Sets the maximum backoff duration between retries.

§Panics

Panics if max_backoff is less than 500ms.

Source

pub fn get_max_backoff(&self) -> Duration

Returns the maximum backoff duration.

Source

pub async fn execute(&self, client: &Client) -> Result<FeeEstimateResponse>

Executes the fee estimate query against the mirror node REST API.

§Errors
  • If no transaction bytes have been set.
  • If the mirror node returns an unrecoverable error.
  • If all retry attempts are exhausted.

Trait Implementations§

Source§

impl Default for FeeEstimateQuery

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more