pub struct Transaction<'a, T: JsonRpcClient> {
pub id: TxHash,
/* private fields */
}Expand description
A high-level struct to manage a transaction.
This is the high-level representation of a transaction. It can be used to confirm a transaction.
Fields§
§id: TxHashHash of the transaction.
Implementations§
Source§impl<'a, T: JsonRpcClient> Transaction<'a, T>
impl<'a, T: JsonRpcClient> Transaction<'a, T>
Sourcepub fn new(id: TxHash, client: &'a Provider<T>) -> Self
pub fn new(id: TxHash, client: &'a Provider<T>) -> Self
Creates a new Transaction.
To create a new transaction you need to pass a hash, which identifies a transaction uniquely, and a provider, which is used to confirm the transaction.
Sourcepub async fn confirm(&self) -> Result<GetTransactionResponse, Error>
pub async fn confirm(&self) -> Result<GetTransactionResponse, Error>
Tries to confirm a transaction.
Sourcepub async fn try_confirm(
&self,
interval: Duration,
max_attempt: u32,
) -> Result<GetTransactionResponse, Error>
pub async fn try_confirm( &self, interval: Duration, max_attempt: u32, ) -> Result<GetTransactionResponse, Error>
The try_confirm function attempts to confirm a transaction by making repeated requests to a
client, with a specified interval and maximum number of attempts, and returns the result.
Arguments:
interval: Theintervalparameter is the duration of time to wait between each attempt to confirm the transaction. It is of typetokio::time::Duration, which represents a duration of time in the Tokio runtime.max_attempt: Themax_attemptparameter is the maximum number of attempts to confirm the transaction.
Trait Implementations§
Auto Trait Implementations§
impl<'a, T> !Freeze for Transaction<'a, T>
impl<'a, T> !RefUnwindSafe for Transaction<'a, T>
impl<'a, T> Send for Transaction<'a, T>
impl<'a, T> !Sync for Transaction<'a, T>
impl<'a, T> Unpin for Transaction<'a, T>
impl<'a, T> UnwindSafe for Transaction<'a, T>where
T: RefUnwindSafe,
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
Mutably borrows from an owned value. Read more