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
impl FeeEstimateQuery
Sourcepub fn set_mode(self, mode: FeeEstimateMode) -> Self
pub fn set_mode(self, mode: FeeEstimateMode) -> Self
Sets the fee estimation mode.
Sourcepub fn get_mode(&self) -> FeeEstimateMode
pub fn get_mode(&self) -> FeeEstimateMode
Returns the fee estimation mode.
Sourcepub fn set_transaction<D: TransactionExecute>(
self,
transaction: &mut Transaction<D>,
client: &Client,
) -> Result<Self>
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.
Sourcepub fn set_transaction_bytes(self, bytes: Vec<u8>) -> Self
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().
Sourcepub fn get_transaction_bytes(&self) -> Option<&[u8]>
pub fn get_transaction_bytes(&self) -> Option<&[u8]>
Returns the transaction bytes, if set.
Sourcepub fn set_high_volume_throttle(self, basis_points: u32) -> Self
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.
Sourcepub fn get_high_volume_throttle(&self) -> Option<u32>
pub fn get_high_volume_throttle(&self) -> Option<u32>
Returns the high-volume throttle, if set.
Sourcepub fn set_max_attempts(self, max_attempts: usize) -> Self
pub fn set_max_attempts(self, max_attempts: usize) -> Self
Sets the maximum number of retry attempts.
Sourcepub fn get_max_attempts(&self) -> usize
pub fn get_max_attempts(&self) -> usize
Returns the maximum number of retry attempts.
Sourcepub fn set_max_backoff(self, max_backoff: Duration) -> Self
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.
Sourcepub fn get_max_backoff(&self) -> Duration
pub fn get_max_backoff(&self) -> Duration
Returns the maximum backoff duration.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FeeEstimateQuery
impl RefUnwindSafe for FeeEstimateQuery
impl Send for FeeEstimateQuery
impl Sync for FeeEstimateQuery
impl Unpin for FeeEstimateQuery
impl UnsafeUnpin for FeeEstimateQuery
impl UnwindSafe for FeeEstimateQuery
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request