pub struct Provider { /* private fields */ }
Expand description
Encapsulates common client operations in the SDK.
Note that you may also use client
, which is an instance
of FuelClient
, directly, which provides a broader API.
Implementations§
Source§impl Provider
impl Provider
pub async fn from(addr: impl Into<SocketAddr>) -> Result<Self>
pub async fn healthy(&self) -> Result<bool>
Sourcepub async fn connect(url: impl AsRef<str>) -> Result<Provider>
pub async fn connect(url: impl AsRef<str>) -> Result<Provider>
Connects to an existing node at the given address.
pub fn url(&self) -> &str
pub async fn blob(&self, blob_id: BlobId) -> Result<Option<Blob>>
pub async fn blob_exists(&self, blob_id: BlobId) -> Result<bool>
Sourcepub async fn send_transaction_and_await_commit<T: Transaction>(
&self,
tx: T,
) -> Result<TxStatus>
pub async fn send_transaction_and_await_commit<T: Transaction>( &self, tx: T, ) -> Result<TxStatus>
Sends a transaction to the underlying Provider’s client.
pub async fn send_transaction<T: Transaction>(&self, tx: T) -> Result<TxId>
pub async fn await_transaction_commit<T: Transaction>( &self, id: TxId, ) -> Result<TxStatus>
pub async fn tx_status(&self, tx_id: &TxId) -> Result<TxStatus>
pub async fn chain_info(&self) -> Result<ChainInfo>
pub fn consensus_parameters(&self) -> &ConsensusParameters
pub fn base_asset_id(&self) -> &AssetId
pub fn chain_id(&self) -> ChainId
pub async fn node_info(&self) -> Result<NodeInfo>
pub async fn latest_gas_price(&self) -> Result<LatestGasPrice>
pub async fn estimate_gas_price( &self, block_horizon: u32, ) -> Result<EstimateGasPrice>
pub async fn dry_run(&self, tx: impl Transaction) -> Result<TxStatus>
pub async fn dry_run_multiple( &self, transactions: Transactions, ) -> Result<Vec<(TxId, TxStatus)>>
pub async fn dry_run_opt( &self, tx: impl Transaction, utxo_validation: bool, gas_price: Option<u64>, ) -> Result<TxStatus>
pub async fn dry_run_opt_multiple( &self, transactions: Transactions, utxo_validation: bool, gas_price: Option<u64>, ) -> Result<Vec<(TxId, TxStatus)>>
Sourcepub async fn get_coins(
&self,
from: &Bech32Address,
asset_id: AssetId,
) -> Result<Vec<Coin>>
pub async fn get_coins( &self, from: &Bech32Address, asset_id: AssetId, ) -> Result<Vec<Coin>>
Gets all unspent coins owned by address from
, with asset ID asset_id
.
Sourcepub async fn get_spendable_resources(
&self,
filter: ResourceFilter,
) -> Result<Vec<CoinType>>
pub async fn get_spendable_resources( &self, filter: ResourceFilter, ) -> Result<Vec<CoinType>>
Get some spendable coins of asset asset_id
for address from
that add up at least to
amount amount
. The returned coins (UTXOs) are actual coins that can be spent. The number
of coins (UXTOs) is optimized to prevent dust accumulation.
Sourcepub async fn get_asset_balance(
&self,
address: &Bech32Address,
asset_id: AssetId,
) -> Result<u64>
pub async fn get_asset_balance( &self, address: &Bech32Address, asset_id: AssetId, ) -> Result<u64>
Get the balance of all spendable coins asset_id
for address address
. This is different
from getting coins because we are just returning a number (the sum of UTXOs amount) instead
of the UTXOs.
Sourcepub async fn get_contract_asset_balance(
&self,
contract_id: &Bech32ContractId,
asset_id: AssetId,
) -> Result<u64>
pub async fn get_contract_asset_balance( &self, contract_id: &Bech32ContractId, asset_id: AssetId, ) -> Result<u64>
Get the balance of all spendable coins asset_id
for contract with id contract_id
.
Sourcepub async fn get_balances(
&self,
address: &Bech32Address,
) -> Result<HashMap<String, u64>>
pub async fn get_balances( &self, address: &Bech32Address, ) -> Result<HashMap<String, u64>>
Get all the spendable balances of all assets for address address
. This is different from
getting the coins because we are only returning the numbers (the sum of UTXOs coins amount
for each asset id) and not the UTXOs coins themselves
Sourcepub async fn get_contract_balances(
&self,
contract_id: &Bech32ContractId,
) -> Result<HashMap<AssetId, u64>>
pub async fn get_contract_balances( &self, contract_id: &Bech32ContractId, ) -> Result<HashMap<AssetId, u64>>
Get all balances of all assets for the contract with id contract_id
.
pub async fn get_transaction_by_id( &self, tx_id: &TxId, ) -> Result<Option<TransactionResponse>>
pub async fn get_transactions( &self, request: PaginationRequest<String>, ) -> Result<PaginatedResult<TransactionResponse, String>>
pub async fn get_transactions_by_owner( &self, owner: &Bech32Address, request: PaginationRequest<String>, ) -> Result<PaginatedResult<TransactionResponse, String>>
pub async fn latest_block_height(&self) -> Result<u32>
pub async fn latest_block_time(&self) -> Result<Option<DateTime<Utc>>>
pub async fn produce_blocks( &self, blocks_to_produce: u32, start_time: Option<DateTime<Utc>>, ) -> Result<u32>
pub async fn block(&self, block_id: &Bytes32) -> Result<Option<Block>>
pub async fn block_by_height( &self, height: BlockHeight, ) -> Result<Option<Block>>
pub async fn get_blocks( &self, request: PaginationRequest<String>, ) -> Result<PaginatedResult<Block, String>>
pub async fn estimate_transaction_cost<T: Transaction>( &self, tx: T, tolerance: Option<f64>, block_horizon: Option<u32>, ) -> Result<TransactionCost>
pub async fn get_messages(&self, from: &Bech32Address) -> Result<Vec<Message>>
pub async fn get_message_proof( &self, tx_id: &TxId, nonce: &Nonce, commit_block_id: Option<&Bytes32>, commit_block_height: Option<u32>, ) -> Result<Option<MessageProof>>
pub async fn is_user_account(&self, address: impl Into<Bytes32>) -> Result<bool>
pub fn with_retry_config(self, retry_config: RetryConfig) -> Self
pub async fn contract_exists( &self, contract_id: &Bech32ContractId, ) -> Result<bool>
Trait Implementations§
Source§impl DryRunner for Provider
impl DryRunner for Provider
fn dry_run<'life0, 'async_trait>(
&'life0 self,
tx: FuelTransaction,
) -> Pin<Box<dyn Future<Output = Result<DryRun>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn estimate_gas_price<'life0, 'async_trait>(
&'life0 self,
block_horizon: u32,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn consensus_parameters(&self) -> &ConsensusParameters
fn maybe_estimate_predicates<'life0, 'life1, 'async_trait>(
&'life0 self,
tx: &'life1 FuelTransaction,
_latest_chain_executor_version: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Option<FuelTransaction>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Auto Trait Implementations§
impl Freeze for Provider
impl !RefUnwindSafe for Provider
impl Send for Provider
impl Sync for Provider
impl Unpin for Provider
impl !UnwindSafe for Provider
Blanket Implementations§
Source§impl<T> AnyDebug for T
impl<T> AnyDebug for T
Source§fn as_any_ref(&self) -> &(dyn Any + 'static)
fn as_any_ref(&self) -> &(dyn Any + 'static)
Any
.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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<S> IteratorOverTable for S
impl<S> IteratorOverTable for S
Source§fn iter_all_keys<M>(
&self,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<<M as Mappable>::OwnedKey, Error>>where
M: Mappable,
Self: IterableTable<M>,
fn iter_all_keys<M>(
&self,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<<M as Mappable>::OwnedKey, Error>>where
M: Mappable,
Self: IterableTable<M>,
Source§fn iter_all_by_prefix_keys<M, P>(
&self,
prefix: Option<P>,
) -> BoxedIter<'_, Result<<M as Mappable>::OwnedKey, Error>>
fn iter_all_by_prefix_keys<M, P>( &self, prefix: Option<P>, ) -> BoxedIter<'_, Result<<M as Mappable>::OwnedKey, Error>>
Source§fn iter_all_by_start_keys<M>(
&self,
start: Option<&<M as Mappable>::Key>,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<<M as Mappable>::OwnedKey, Error>>where
M: Mappable,
Self: IterableTable<M>,
fn iter_all_by_start_keys<M>(
&self,
start: Option<&<M as Mappable>::Key>,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<<M as Mappable>::OwnedKey, Error>>where
M: Mappable,
Self: IterableTable<M>,
Source§fn iter_all_filtered_keys<M, P>(
&self,
prefix: Option<P>,
start: Option<&<M as Mappable>::Key>,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<<M as Mappable>::OwnedKey, Error>>
fn iter_all_filtered_keys<M, P>( &self, prefix: Option<P>, start: Option<&<M as Mappable>::Key>, direction: Option<IterDirection>, ) -> BoxedIter<'_, Result<<M as Mappable>::OwnedKey, Error>>
Source§fn iter_all<M>(
&self,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>where
M: Mappable,
Self: IterableTable<M>,
fn iter_all<M>(
&self,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>where
M: Mappable,
Self: IterableTable<M>,
Source§fn iter_all_by_prefix<M, P>(
&self,
prefix: Option<P>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>
fn iter_all_by_prefix<M, P>( &self, prefix: Option<P>, ) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>
Source§fn iter_all_by_start<M>(
&self,
start: Option<&<M as Mappable>::Key>,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>where
M: Mappable,
Self: IterableTable<M>,
fn iter_all_by_start<M>(
&self,
start: Option<&<M as Mappable>::Key>,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>where
M: Mappable,
Self: IterableTable<M>,
Source§fn iter_all_filtered<M, P>(
&self,
prefix: Option<P>,
start: Option<&<M as Mappable>::Key>,
direction: Option<IterDirection>,
) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>
fn iter_all_filtered<M, P>( &self, prefix: Option<P>, start: Option<&<M as Mappable>::Key>, direction: Option<IterDirection>, ) -> BoxedIter<'_, Result<(<M as Mappable>::OwnedKey, <M as Mappable>::OwnedValue), Error>>
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.Source§impl<T> StorageAsMut for T
impl<T> StorageAsMut for T
fn storage<Type>(&mut self) -> StorageMut<'_, Self, Type>where
Type: Mappable,
fn storage_as_mut<Type>(&mut self) -> StorageMut<'_, Self, Type>where
Type: Mappable,
Source§impl<T> StorageAsRef for T
impl<T> StorageAsRef for T
fn storage<Type>(&self) -> StorageRef<'_, Self, Type>where
Type: Mappable,
fn storage_as_ref<Type>(&self) -> StorageRef<'_, Self, Type>where
Type: Mappable,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.