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, ()>
impl<T: Transport> MethodBuilder<T, ()>
source§impl<T: Transport, R: Tokenize> MethodBuilder<T, R>
impl<T: Transport, R: Tokenize> MethodBuilder<T, R>
sourcepub fn new(
web3: Web3<T>,
function: Function,
address: Address,
data: Bytes
) -> Self
pub fn new( web3: Web3<T>, function: Function, address: Address, data: Bytes ) -> Self
Creates a new builder for a transaction.
sourcepub fn with_defaults(self, defaults: &MethodDefaults) -> Self
pub fn with_defaults(self, defaults: &MethodDefaults) -> Self
Apply method defaults to this builder.
sourcepub fn function(&self) -> &Function
pub fn function(&self) -> &Function
Returns a reference to the underling ABI function for this call.
sourcepub fn from(self, value: Account) -> Self
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.
sourcepub fn gas(self, value: U256) -> Self
pub fn gas(self, value: U256) -> Self
Secify amount of gas to use, if not specified then a gas estimate will be used.
sourcepub fn gas_price(self, value: GasPrice) -> Self
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.
sourcepub fn value(self, value: U256) -> Self
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.
sourcepub fn nonce(self, value: U256) -> Self
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.
sourcepub fn confirmations(self, value: usize) -> Self
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.
sourcepub fn access_list(self, value: AccessList) -> Self
pub fn access_list(self, value: AccessList) -> Self
Specify the access list for the transaction, if not specified no access list will be used.
sourcepub fn into_inner(self) -> TransactionBuilder<T>
pub fn into_inner(self) -> TransactionBuilder<T>
Extract inner TransactionBuilder from this SendBuilder. This exposes
TransactionBuilder only APIs.
sourcepub async fn send(self) -> Result<TransactionResult, MethodError>
pub async fn send(self) -> Result<TransactionResult, MethodError>
Sign (if required) and send the method call transaction.
sourcepub fn view(self) -> ViewMethodBuilder<T, R>
pub fn view(self) -> ViewMethodBuilder<T, R>
Demotes a MethodBuilder into a ViewMethodBuilder which has a more
restricted API and cannot actually send transactions.
sourcepub async fn call(self) -> Result<R, MethodError>
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.