pub struct PendingTransactionBuilder<N: Network> { /* private fields */ }
Expand description
A builder for configuring a pending transaction watcher.
§Examples
Send and wait for a transaction to be confirmed 2 times, with a timeout of 60 seconds:
// Send a transaction, and configure the pending transaction.
let builder = provider.send_transaction(tx)
.await?
.with_required_confirmations(2)
.with_timeout(Some(std::time::Duration::from_secs(60)));
// Register the pending transaction with the provider.
let pending_tx = builder.register().await?;
// Wait for the transaction to be confirmed 2 times.
let tx_hash = pending_tx.await?;
This can also be more concisely written using watch
:
let tx_hash = provider.send_transaction(tx)
.await?
.with_required_confirmations(2)
.with_timeout(Some(std::time::Duration::from_secs(60)))
.watch()
.await?;
Implementations§
Source§impl<N: Network> PendingTransactionBuilder<N>
impl<N: Network> PendingTransactionBuilder<N>
Sourcepub const fn new(provider: RootProvider<N>, tx_hash: TxHash) -> Self
pub const fn new(provider: RootProvider<N>, tx_hash: TxHash) -> Self
Creates a new pending transaction builder.
Sourcepub const fn from_config(
provider: RootProvider<N>,
config: PendingTransactionConfig,
) -> Self
pub const fn from_config( provider: RootProvider<N>, config: PendingTransactionConfig, ) -> Self
Creates a new pending transaction builder from the given configuration.
Sourcepub const fn inner(&self) -> &PendingTransactionConfig
pub const fn inner(&self) -> &PendingTransactionConfig
Returns the inner configuration.
Sourcepub fn into_inner(self) -> PendingTransactionConfig
pub fn into_inner(self) -> PendingTransactionConfig
Consumes this builder, returning the inner configuration.
Sourcepub const fn provider(&self) -> &RootProvider<N>
pub const fn provider(&self) -> &RootProvider<N>
Returns the provider.
Sourcepub fn split(self) -> (RootProvider<N>, PendingTransactionConfig)
pub fn split(self) -> (RootProvider<N>, PendingTransactionConfig)
Consumes this builder, returning the provider and the configuration.
Sourcepub fn set_tx_hash(&mut self, tx_hash: TxHash)
pub fn set_tx_hash(&mut self, tx_hash: TxHash)
Sets the transaction hash.
Sourcepub const fn with_tx_hash(self, tx_hash: TxHash) -> Self
pub const fn with_tx_hash(self, tx_hash: TxHash) -> Self
Sets the transaction hash.
Sourcepub const fn required_confirmations(&self) -> u64
pub const fn required_confirmations(&self) -> u64
Returns the number of confirmations to wait for.
Sourcepub fn set_required_confirmations(&mut self, confirmations: u64)
pub fn set_required_confirmations(&mut self, confirmations: u64)
Sets the number of confirmations to wait for.
Sourcepub const fn with_required_confirmations(self, confirmations: u64) -> Self
pub const fn with_required_confirmations(self, confirmations: u64) -> Self
Sets the number of confirmations to wait for.
Sourcepub fn set_timeout(&mut self, timeout: Option<Duration>)
pub fn set_timeout(&mut self, timeout: Option<Duration>)
Sets the timeout.
Sourcepub const fn with_timeout(self, timeout: Option<Duration>) -> Self
pub const fn with_timeout(self, timeout: Option<Duration>) -> Self
Sets the timeout.
Sourcepub async fn register(
self,
) -> Result<PendingTransaction, PendingTransactionError>
pub async fn register( self, ) -> Result<PendingTransaction, PendingTransactionError>
Registers the watching configuration with the provider.
This does not wait for the transaction to be confirmed, but returns a PendingTransaction
that can be awaited at a later moment.
See:
watch
for watching the transaction without fetching the receipt.get_receipt
for fetching the receipt after the transaction has been confirmed.
Sourcepub async fn watch(self) -> Result<TxHash, PendingTransactionError>
pub async fn watch(self) -> Result<TxHash, PendingTransactionError>
Waits for the transaction to confirm with the given number of confirmations.
See:
register
: for registering the transaction without waiting for it to be confirmed.get_receipt
for fetching the receipt after the transaction has been confirmed.
Sourcepub async fn get_receipt(
self,
) -> Result<N::ReceiptResponse, PendingTransactionError>
pub async fn get_receipt( self, ) -> Result<N::ReceiptResponse, PendingTransactionError>
Waits for the transaction to confirm with the given number of confirmations, and then fetches its receipt.
Note that this method will call eth_getTransactionReceipt
on the root
provider, and not on a specific network provider. This means that any
overrides or customizations made to the network provider will not be used.
See:
Trait Implementations§
Auto Trait Implementations§
impl<N> Freeze for PendingTransactionBuilder<N>
impl<N> !RefUnwindSafe for PendingTransactionBuilder<N>
impl<N> Send for PendingTransactionBuilder<N>
impl<N> Sync for PendingTransactionBuilder<N>
impl<N> Unpin for PendingTransactionBuilder<N>
impl<N> !UnwindSafe for PendingTransactionBuilder<N>
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> 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<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 64 bytes