pub struct TransactionRequest {Show 15 fields
pub from: Option<Address>,
pub to: Option<TxKind>,
pub gas_price: Option<u128>,
pub max_fee_per_gas: Option<u128>,
pub max_priority_fee_per_gas: Option<u128>,
pub max_fee_per_blob_gas: Option<u128>,
pub gas: Option<u128>,
pub value: Option<U256>,
pub input: TransactionInput,
pub nonce: Option<u64>,
pub chain_id: Option<ChainId>,
pub access_list: Option<AccessList>,
pub transaction_type: Option<u8>,
pub blob_versioned_hashes: Option<Vec<B256>>,
pub sidecar: Option<BlobTransactionSidecar>,
}
Expand description
Represents all transaction requests to/from RPC.
Fields§
§from: Option<Address>
The address of the transaction author.
to: Option<TxKind>
The destination address of the transaction.
gas_price: Option<u128>
The legacy gas price.
max_fee_per_gas: Option<u128>
The max base fee per gas the sender is willing to pay.
max_priority_fee_per_gas: Option<u128>
The max priority fee per gas the sender is willing to pay, also called the miner tip.
max_fee_per_blob_gas: Option<u128>
The max fee per blob gas for EIP-4844 blob transactions.
gas: Option<u128>
The gas limit for the transaction.
value: Option<U256>
The value transferred in the transaction, in wei.
input: TransactionInput
Transaction data.
nonce: Option<u64>
The nonce of the transaction.
chain_id: Option<ChainId>
The chain ID for the transaction.
access_list: Option<AccessList>
An EIP-2930 access list, which lowers cost for accessing accounts and storages in the list. See EIP-2930 for more information.
transaction_type: Option<u8>
The EIP-2718 transaction type. See EIP-2718 for more information.
blob_versioned_hashes: Option<Vec<B256>>
Blob versioned hashes for EIP-4844 transactions.
sidecar: Option<BlobTransactionSidecar>
Blob sidecar for EIP-4844 transactions.
Implementations§
source§impl TransactionRequest
impl TransactionRequest
sourcepub const fn from(self, from: Address) -> Self
pub const fn from(self, from: Address) -> Self
Sets the from
field in the call to the provided address
sourcepub const fn transaction_type(self, transaction_type: u8) -> Self
pub const fn transaction_type(self, transaction_type: u8) -> Self
Sets the transactions type for the transactions.
sourcepub const fn max_fee_per_gas(self, max_fee_per_gas: u128) -> Self
pub const fn max_fee_per_gas(self, max_fee_per_gas: u128) -> Self
Sets the maximum fee per gas for the transaction.
sourcepub const fn max_priority_fee_per_gas(
self,
max_priority_fee_per_gas: u128,
) -> Self
pub const fn max_priority_fee_per_gas( self, max_priority_fee_per_gas: u128, ) -> Self
Sets the maximum priority fee per gas for the transaction.
sourcepub fn access_list(self, access_list: AccessList) -> Self
pub fn access_list(self, access_list: AccessList) -> Self
Sets the access list for the transaction.
sourcepub fn input(self, input: TransactionInput) -> Self
pub fn input(self, input: TransactionInput) -> Self
Sets the input data for the transaction.
sourcepub fn fee_cap(&self) -> Option<u128>
pub fn fee_cap(&self) -> Option<u128>
Returns the configured fee cap, if any.
The returns gas_price
(legacy) if set or max_fee_per_gas
(EIP1559)
sourcepub fn populate_blob_hashes(&mut self)
pub fn populate_blob_hashes(&mut self)
Populate the blob_versioned_hashes
key, if a sidecar exists. No
effect otherwise.
sourcepub fn get_invalid_common_fields(&self) -> Vec<&'static str>
pub fn get_invalid_common_fields(&self) -> Vec<&'static str>
Gets invalid fields for all transaction types
sourcepub fn get_invalid_1559_fields(&self) -> Vec<&'static str>
pub fn get_invalid_1559_fields(&self) -> Vec<&'static str>
Gets invalid fields for EIP-1559 transaction type
sourcefn build_legacy(self) -> TxLegacy
fn build_legacy(self) -> TxLegacy
Build a legacy transaction.
§Panics
If required fields are missing. Use complete_legacy
to check if the
request can be built.
sourcefn build_1559(self) -> TxEip1559
fn build_1559(self) -> TxEip1559
Build an EIP-1559 transaction.
§Panics
If required fields are missing. Use complete_1559
to check if the
request can be built.
sourcefn build_2930(self) -> TxEip2930
fn build_2930(self) -> TxEip2930
Build an EIP-2930 transaction.
§Panics
If required fields are missing. Use complete_2930
to check if the
request can be built.
sourcefn build_4844(self) -> TxEip4844WithSidecar
fn build_4844(self) -> TxEip4844WithSidecar
Build an EIP-4844 transaction.
§Panics
If required fields are missing. Use complete_4844
to check if the
request can be built.
fn check_reqd_fields(&self) -> Vec<&'static str>
fn check_legacy_fields(&self, missing: &mut Vec<&'static str>)
fn check_1559_fields(&self, missing: &mut Vec<&'static str>)
sourcepub fn trim_conflicting_keys(&mut self)
pub fn trim_conflicting_keys(&mut self)
Trim field conflicts, based on the preferred type
This is used to ensure that the request will not be rejected by the server due to conflicting keys, and should only be called before submission via rpc.
sourcepub const fn preferred_type(&self) -> TxType
pub const fn preferred_type(&self) -> TxType
Check this builder’s preferred type, based on the fields that are set.
Types are preferred as follows:
- EIP-4844 if sidecar or max_blob_fee_per_gas is set
- EIP-2930 if access_list is set
- Legacy if gas_price is set and access_list is unset
- EIP-1559 in all other cases
sourcepub fn missing_keys(&self) -> Result<TxType, (TxType, Vec<&'static str>)>
pub fn missing_keys(&self) -> Result<TxType, (TxType, Vec<&'static str>)>
Check if all necessary keys are present to build a transaction.
§Returns
- Ok(type) if all necessary keys are present to build the preferred type.
- Err((type, missing)) if some keys are missing to build the preferred type.
sourcepub fn complete_4844(&self) -> Result<(), Vec<&'static str>>
pub fn complete_4844(&self) -> Result<(), Vec<&'static str>>
Check if all necessary keys are present to build a 4844 transaction, returning a list of keys that are missing.
sourcepub fn complete_1559(&self) -> Result<(), Vec<&'static str>>
pub fn complete_1559(&self) -> Result<(), Vec<&'static str>>
Check if all necessary keys are present to build a 1559 transaction, returning a list of keys that are missing.
sourcepub fn complete_2930(&self) -> Result<(), Vec<&'static str>>
pub fn complete_2930(&self) -> Result<(), Vec<&'static str>>
Check if all necessary keys are present to build a 2930 transaction, returning a list of keys that are missing.
sourcepub fn complete_legacy(&self) -> Result<(), Vec<&'static str>>
pub fn complete_legacy(&self) -> Result<(), Vec<&'static str>>
Check if all necessary keys are present to build a legacy transaction, returning a list of keys that are missing.
sourcepub fn buildable_type(&self) -> Option<TxType>
pub fn buildable_type(&self) -> Option<TxType>
Return the tx type this request can be built as. Computed by checking the preferred type, and then checking for completeness.
sourcepub fn build_typed_tx(self) -> Result<TypedTransaction, Self>
pub fn build_typed_tx(self) -> Result<TypedTransaction, Self>
Build an [TypedTransaction
]
Trait Implementations§
source§impl Clone for TransactionRequest
impl Clone for TransactionRequest
source§fn clone(&self) -> TransactionRequest
fn clone(&self) -> TransactionRequest
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for TransactionRequest
impl Debug for TransactionRequest
source§impl Default for TransactionRequest
impl Default for TransactionRequest
source§fn default() -> TransactionRequest
fn default() -> TransactionRequest
source§impl<'de> Deserialize<'de> for TransactionRequest
impl<'de> Deserialize<'de> for TransactionRequest
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl From<Transaction> for TransactionRequest
impl From<Transaction> for TransactionRequest
source§fn from(tx: Transaction) -> Self
fn from(tx: Transaction) -> Self
source§impl From<TxEip1559> for TransactionRequest
impl From<TxEip1559> for TransactionRequest
source§impl From<TxEip2930> for TransactionRequest
impl From<TxEip2930> for TransactionRequest
source§impl From<TxEip4844> for TransactionRequest
impl From<TxEip4844> for TransactionRequest
source§impl From<TxEip4844Variant> for TransactionRequest
impl From<TxEip4844Variant> for TransactionRequest
source§impl From<TxEip4844WithSidecar> for TransactionRequest
impl From<TxEip4844WithSidecar> for TransactionRequest
source§impl From<TxEnvelope> for TransactionRequest
impl From<TxEnvelope> for TransactionRequest
source§impl From<TxLegacy> for TransactionRequest
impl From<TxLegacy> for TransactionRequest
source§impl From<TypedTransaction> for TransactionRequest
impl From<TypedTransaction> for TransactionRequest
source§impl Hash for TransactionRequest
impl Hash for TransactionRequest
source§impl PartialEq for TransactionRequest
impl PartialEq for TransactionRequest
source§fn eq(&self, other: &TransactionRequest) -> bool
fn eq(&self, other: &TransactionRequest) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for TransactionRequest
impl Serialize for TransactionRequest
impl Eq for TransactionRequest
impl StructuralPartialEq for TransactionRequest
Auto Trait Implementations§
impl !Freeze for TransactionRequest
impl RefUnwindSafe for TransactionRequest
impl Send for TransactionRequest
impl Sync for TransactionRequest
impl Unpin for TransactionRequest
impl UnwindSafe for TransactionRequest
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreimpl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 464 bytes