Struct PendingTransactionBuilder

Source
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>

Source

pub const fn new(provider: RootProvider<N>, tx_hash: TxHash) -> Self

Creates a new pending transaction builder.

Source

pub const fn from_config( provider: RootProvider<N>, config: PendingTransactionConfig, ) -> Self

Creates a new pending transaction builder from the given configuration.

Source

pub const fn inner(&self) -> &PendingTransactionConfig

Returns the inner configuration.

Source

pub fn into_inner(self) -> PendingTransactionConfig

Consumes this builder, returning the inner configuration.

Source

pub const fn provider(&self) -> &RootProvider<N>

Returns the provider.

Source

pub fn split(self) -> (RootProvider<N>, PendingTransactionConfig)

Consumes this builder, returning the provider and the configuration.

Source

pub const fn tx_hash(&self) -> &TxHash

Returns the transaction hash.

Source

pub fn set_tx_hash(&mut self, tx_hash: TxHash)

Sets the transaction hash.

Source

pub const fn with_tx_hash(self, tx_hash: TxHash) -> Self

Sets the transaction hash.

Source

pub const fn required_confirmations(&self) -> u64

Returns the number of confirmations to wait for.

Source

pub fn set_required_confirmations(&mut self, confirmations: u64)

Sets the number of confirmations to wait for.

Source

pub const fn with_required_confirmations(self, confirmations: u64) -> Self

Sets the number of confirmations to wait for.

Source

pub const fn timeout(&self) -> Option<Duration>

Returns the timeout.

Source

pub fn set_timeout(&mut self, timeout: Option<Duration>)

Sets the timeout.

Source

pub const fn with_timeout(self, timeout: Option<Duration>) -> Self

Sets the timeout.

Source

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.
Source

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.
Source

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:

  • register: for registering the transaction without waiting for it to be confirmed.
  • watch for watching the transaction without fetching the receipt.

Trait Implementations§

Source§

impl<N: Debug + Network> Debug for PendingTransactionBuilder<N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
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
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

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