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>
impl<T: Transport> TransactionBuilder<T>
sourcepub async fn build(self) -> Result<Transaction, ExecutionError>
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>
impl<T: Transport> TransactionBuilder<T>
sourcepub async fn send(self) -> Result<TransactionResult, ExecutionError>
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>
impl<T: Transport> TransactionBuilder<T>
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 to(self, value: Address) -> Self
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).
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 data(self, value: Bytes) -> Self
pub fn data(self, value: Bytes) -> Self
Specify the data to use for the transaction, if not specified, then empty data will be used.
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 resolve(self, value: ResolveCondition) -> Self
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).
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 confirmations(self, value: usize) -> Self
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.
sourcepub async fn estimate_gas(self) -> Result<U256, ExecutionError>
pub async fn estimate_gas(self) -> Result<U256, ExecutionError>
Estimate the gas required for this transaction.