Struct ethcontract::contract::MethodBuilder

source ·
pub struct MethodBuilder<T: Transport, R: Tokenize> {
    pub tx: TransactionBuilder<T>,
    /* private fields */
}
Expand description

Data used for building a contract method call or transaction. The method builder can be demoted into a CallBuilder to not allow sending of transactions. This is useful when dealing with view functions.

Fields§

§tx: TransactionBuilder<T>

transaction parameters

Implementations§

source§

impl<T: Transport> MethodBuilder<T, ()>

source

pub fn fallback(web3: Web3<T>, address: Address, data: Bytes) -> Self

Creates a new builder for a transaction invoking the fallback method.

source§

impl<T: Transport, R: Tokenize> MethodBuilder<T, R>

source

pub fn new( web3: Web3<T>, function: Function, address: Address, data: Bytes ) -> Self

Creates a new builder for a transaction.

source

pub fn with_defaults(self, defaults: &MethodDefaults) -> Self

Apply method defaults to this builder.

source

pub fn function(&self) -> &Function

Returns a reference to the underling ABI function for this call.

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 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 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 confirmations(self, value: usize) -> Self

Specify the number of confirmations to wait for when confirming the transaction, if not specified will wait for the transaction to be mined without any extra confirmations.

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 into_inner(self) -> TransactionBuilder<T>

Extract inner TransactionBuilder from this SendBuilder. This exposes TransactionBuilder only APIs.

source

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

Sign (if required) and send the method call transaction.

source

pub fn view(self) -> ViewMethodBuilder<T, R>

Demotes a MethodBuilder into a ViewMethodBuilder which has a more restricted API and cannot actually send transactions.

source

pub async fn call(self) -> Result<R, MethodError>

Call a contract method. Contract calls do not modify the blockchain and as such do not require gas or signing. Note that doing a call with a block number requires first demoting the MethodBuilder into a ViewMethodBuilder and setting the block number for the call.

Trait Implementations§

source§

impl<T: Clone + Transport, R: Clone + Tokenize> Clone for MethodBuilder<T, R>

source§

fn clone(&self) -> MethodBuilder<T, R>

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, R: Debug + Tokenize> Debug for MethodBuilder<T, R>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T, R> Freeze for MethodBuilder<T, R>
where T: Freeze,

§

impl<T, R> RefUnwindSafe for MethodBuilder<T, R>

§

impl<T, R> Send for MethodBuilder<T, R>
where T: Send, R: Send,

§

impl<T, R> Sync for MethodBuilder<T, R>
where T: Sync, R: Sync,

§

impl<T, R> Unpin for MethodBuilder<T, R>
where T: Unpin, R: Unpin,

§

impl<T, R> UnwindSafe for MethodBuilder<T, R>
where T: UnwindSafe, R: 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