Struct ethcontract::transaction::TransactionBuilder

source ·
pub struct TransactionBuilder<T: Transport> {
    pub from: Option<Account>,
    pub to: Option<Address>,
    pub gas: Option<U256>,
    pub gas_price: Option<GasPrice>,
    pub value: Option<U256>,
    pub data: Option<Bytes>,
    pub nonce: Option<U256>,
    pub resolve: Option<ResolveCondition>,
    pub access_list: Option<AccessList>,
    /* private fields */
}
Expand description

Data used for building a transaction that modifies the blockchain. These transactions can either be sent to be signed locally by the node or can be signed offline.

Fields§

§from: Option<Account>

The sender of the transaction with the signing strategy to use. Defaults to locally signing on the node with the default acount.

§to: Option<Address>

The receiver of the transaction.

§gas: Option<U256>

Optional gas amount to use for transaction. Defaults to estimated gas.

§gas_price: Option<GasPrice>

Optional gas price to use for transaction. Defaults to None.

§value: Option<U256>

The ETH value to send with the transaction. Defaults to 0.

§data: Option<Bytes>

The data for the transaction. Defaults to empty data.

§nonce: Option<U256>

Optional nonce to use. Defaults to the signing account’s current transaction count.

§resolve: Option<ResolveCondition>

Optional resolve conditions. Defaults to waiting the transaction to be mined without any extra confirmation blocks.

§access_list: Option<AccessList>

Access list

Implementations§

source§

impl<T: Transport> TransactionBuilder<T>

source

pub async fn build(self) -> Result<Transaction, ExecutionError>

Build a prepared transaction that is ready to send.

Can resolve into either a TransactionRequest for sending locally signed transactions or raw signed transaction Bytes when sending a raw transaction.

source§

impl<T: Transport> TransactionBuilder<T>

source

pub async fn send(self) -> Result<TransactionResult, ExecutionError>

Sign (if required) and send the transaction. Returns the transaction hash that can be used to retrieve transaction information.

source§

impl<T: Transport> TransactionBuilder<T>

source

pub fn new(web3: Web3<T>) -> Self

Creates a new builder for a transaction.

source

pub fn from(self, value: Account) -> Self

Specify the signing method to use for the transaction, if not specified the the transaction will be locally signed with the default user.

source

pub fn to(self, value: Address) -> Self

Specify the recepient of the transaction, if not specified the transaction will be sent to the 0 address (for deploying contracts).

source

pub fn gas(self, value: U256) -> Self

Secify amount of gas to use, if not specified then a gas estimate will be used.

source

pub fn gas_price(self, value: GasPrice) -> Self

Specify the gas price to use, if not specified then the estimated gas price will be used.

source

pub fn value(self, value: U256) -> Self

Specify what how much ETH to transfer with the transaction, if not specified then no ETH will be sent.

source

pub fn data(self, value: Bytes) -> Self

Specify the data to use for the transaction, if not specified, then empty data will be used.

source

pub fn nonce(self, value: U256) -> Self

Specify the nonce for the transation, if not specified will use the current transaction count for the signing account.

source

pub fn resolve(self, value: ResolveCondition) -> Self

Specify the resolve condition, if not specified will default to waiting for the transaction to be mined (but not confirmed by any extra blocks).

source

pub fn access_list(self, value: AccessList) -> Self

Specify the access list for the transaction, if not specified no access list will be used.

source

pub fn confirmations(self, value: usize) -> Self

Specify the number of confirmations to use for the confirmation options. This is a utility method for specifying the resolve condition.

source

pub async fn estimate_gas(self) -> Result<U256, ExecutionError>

Estimate the gas required for this transaction.

Trait Implementations§

source§

impl<T: Clone + Transport> Clone for TransactionBuilder<T>

source§

fn clone(&self) -> TransactionBuilder<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug + Transport> Debug for TransactionBuilder<T>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for TransactionBuilder<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for TransactionBuilder<T>
where T: RefUnwindSafe,

§

impl<T> Send for TransactionBuilder<T>
where T: Send,

§

impl<T> Sync for TransactionBuilder<T>
where T: Sync,

§

impl<T> Unpin for TransactionBuilder<T>
where T: Unpin,

§

impl<T> UnwindSafe for TransactionBuilder<T>
where T: UnwindSafe,

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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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