Struct ethers_contract::FunctionCall
source · pub struct FunctionCall<B, M, D> {
pub tx: TypedTransaction,
pub function: Function,
pub block: Option<BlockId>,
/* private fields */
}
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,
impl<B, M, D> FunctionCall<B, M, D>where
B: Borrow<M>,
D: Detokenize,
sourcepub fn from<T: Into<Address>>(self, from: T) -> Self
pub fn from<T: Into<Address>>(self, from: T) -> Self
Sets the from
field in the transaction to the provided value
sourcepub fn legacy(self) -> Self
pub fn legacy(self) -> Self
Uses a Legacy transaction instead of an EIP-1559 one to execute the call
sourcepub fn gas<T: Into<U256>>(self, gas: T) -> Self
pub fn gas<T: Into<U256>>(self, gas: T) -> Self
Sets the gas
field in the transaction to the provided value
sourcepub fn gas_price<T: Into<U256>>(self, gas_price: T) -> Self
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
sourcepub fn value<T: Into<U256>>(self, value: T) -> Self
pub fn value<T: Into<U256>>(self, value: T) -> Self
Sets the value
field in the transaction to the provided value
source§impl<B, M, D> FunctionCall<B, M, D>
impl<B, M, D> FunctionCall<B, M, D>
sourcepub async fn estimate_gas(&self) -> Result<U256, ContractError<M>>
pub async fn estimate_gas(&self) -> Result<U256, ContractError<M>>
Returns the estimated gas cost for the underlying transaction to be executed
sourcepub async fn call(&self) -> Result<D, ContractError<M>>
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
sourcepub fn call_raw(
&self
) -> impl RawCall<'_> + Future<Output = Result<D, ContractError<M>>> + Debug
pub fn call_raw( &self ) -> impl RawCall<'_> + Future<Output = Result<D, ContractError<M>>> + Debug
Returns an implementer of RawCall
which can be .await
d 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
sourcepub fn call_raw_bytes(&self) -> CallBuilder<'_, M::Provider>
pub fn call_raw_bytes(&self) -> CallBuilder<'_, M::Provider>
Returns a CallBuilder
which can be .await
d 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
sourcepub async fn send(
&self
) -> Result<PendingTransaction<'_, M::Provider>, ContractError<M>>
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,
impl<B, M, D> Clone for FunctionCall<B, M, D>where
B: Clone,
source§impl<B, M, D> IntoFuture for FunctionCall<B, M, D>
impl<B, M, D> IntoFuture for FunctionCall<B, M, D>
FunctionCall
can be turned into Future
automatically with .await
.
Defaults to calling FunctionCall::call
.