pub struct FunctionCall<B, M, D> {
    pub tx: TypedTransaction,
    pub function: Function,
    pub block: Option<BlockId>,
    /* private fields */
}
Available on crate feature providers only.
Expand description

Helper for managing a transaction before submitting it to a node

Fields§

§tx: TypedTransaction

The raw transaction object

§function: Function

The ABI of the function being called

§block: Option<BlockId>

Optional block number to be used when calculating the transaction’s gas and nonce

Implementations§

source§

impl<B, M, D> FunctionCall<B, M, D>
where B: Borrow<M>, D: Detokenize,

source

pub fn from<T: Into<Address>>(self, from: T) -> Self

Sets the from field in the transaction to the provided value

source

pub fn legacy(self) -> Self

Uses a Legacy transaction instead of an EIP-1559 one to execute the call

source

pub fn gas<T: Into<U256>>(self, gas: T) -> Self

Sets the gas field in the transaction to the provided value

source

pub fn gas_price<T: Into<U256>>(self, gas_price: T) -> Self

Sets the gas_price field in the transaction to the provided value If the internal transaction is an EIP-1559 one, then it sets both max_fee_per_gas and max_priority_fee_per_gas to the same value

source

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

Sets the value field in the transaction to the provided value

source

pub fn block<T: Into<BlockId>>(self, block: T) -> Self

Sets the block field for sending the tx to the chain

source

pub fn nonce<T: Into<U256>>(self, nonce: T) -> Self

Sets the nonce field in the transaction to the provided value

source§

impl<B, M, D> FunctionCall<B, M, D>
where B: Borrow<M>, M: Middleware, D: Detokenize,

source

pub fn calldata(&self) -> Option<Bytes>

Returns the underlying transaction’s ABI encoded data

source

pub async fn estimate_gas(&self) -> Result<U256, ContractError<M>>

Returns the estimated gas cost for the underlying transaction to be executed

source

pub async fn call(&self) -> Result<D, ContractError<M>>

Queries the blockchain via an eth_call for the provided transaction.

If executed on a non-state mutating smart contract function (i.e. view, pure) then it will return the raw data from the chain.

If executed on a mutating smart contract function, it will do a “dry run” of the call and return the return type of the transaction without mutating the state

Note: this function does not send a transaction from your account

source

pub fn call_raw( &self ) -> impl RawCall<'_> + Future<Output = Result<D, ContractError<M>>> + Debug

Returns an implementer of RawCall which can be .awaitd to query the blockchain via eth_call, returning the deoded return data.

The returned call can also be used to override the input parameters to eth_call.

Note: this function does not send a transaction from your account

source

pub fn call_raw_bytes(&self) -> CallBuilder<'_, M::Provider>

Returns a CallBuilder which can be .awaitd to query the blochcain via eth_call, returning the raw bytes from the transaction.

The returned call can also be used to override the input parameters to eth_call.

Note: this function does not send a transaction from your account

source

pub async fn send( &self ) -> Result<PendingTransaction<'_, M::Provider>, ContractError<M>>

Signs and broadcasts the provided transaction

Trait Implementations§

source§

impl<B, M, D> Clone for FunctionCall<B, M, D>
where B: Clone,

source§

fn clone(&self) -> Self

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<B: Debug, M: Debug, D: Debug> Debug for FunctionCall<B, M, D>

source§

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

Formats the value using the given formatter. Read more
source§

impl<B, M, D> IntoFuture for FunctionCall<B, M, D>
where Self: 'static, B: Borrow<M> + Send + Sync, M: Middleware, D: Detokenize + Send + Sync,

FunctionCall can be turned into Future automatically with .await. Defaults to calling FunctionCall::call.

§

type Output = Result<D, ContractError<M>>

The output that the future will produce on completion.
§

type IntoFuture = Pin<Box<dyn Future<Output = <FunctionCall<B, M, D> as IntoFuture>::Output> + Send>>

Which kind of future are we turning this into?
source§

fn into_future(self) -> Self::IntoFuture

Creates a future from a value. Read more

Auto Trait Implementations§

§

impl<B, M, D> RefUnwindSafe for FunctionCall<B, M, D>

§

impl<B, M, D> Send for FunctionCall<B, M, D>
where B: Send, D: Send, M: Send,

§

impl<B, M, D> Sync for FunctionCall<B, M, D>
where B: Sync, D: Sync, M: Sync,

§

impl<B, M, D> Unpin for FunctionCall<B, M, D>
where B: Unpin, D: Unpin, M: Unpin,

§

impl<B, M, D> UnwindSafe for FunctionCall<B, M, D>
where B: UnwindSafe, D: UnwindSafe, M: 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> 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
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> JsonSchemaMaybe for T