pub struct TransactionRequest {Show 16 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<u64>,
pub value: Option<Uint<256, 4>>,
pub input: TransactionInput,
pub nonce: Option<u64>,
pub chain_id: Option<u64>,
pub access_list: Option<AccessList>,
pub transaction_type: Option<u8>,
pub blob_versioned_hashes: Option<Vec<FixedBytes<32>>>,
pub sidecar: Option<BlobTransactionSidecar>,
pub authorization_list: Option<Vec<SignedAuthorization>>,
}
eth
only.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<u64>
The gas limit for the transaction.
value: Option<Uint<256, 4>>
The value transferred in the transaction, in wei.
input: TransactionInput
Transaction data.
nonce: Option<u64>
The nonce of the transaction.
chain_id: Option<u64>
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<FixedBytes<32>>>
Blob versioned hashes for EIP-4844 transactions.
sidecar: Option<BlobTransactionSidecar>
Blob sidecar for EIP-4844 transactions.
Authorization list for for EIP-7702 transactions.
Implementations§
Source§impl TransactionRequest
impl TransactionRequest
Sourcepub const fn from(self, from: Address) -> TransactionRequest
pub const fn from(self, from: Address) -> TransactionRequest
Sets the from
field in the call to the provided address
Sourcepub const fn transaction_type(self, transaction_type: u8) -> TransactionRequest
pub const fn transaction_type(self, transaction_type: u8) -> TransactionRequest
Sets the transactions type for the transactions.
Sourcepub const fn gas_limit(self, gas_limit: u64) -> TransactionRequest
pub const fn gas_limit(self, gas_limit: u64) -> TransactionRequest
Sets the gas limit for the transaction.
Sourcepub const fn nonce(self, nonce: u64) -> TransactionRequest
pub const fn nonce(self, nonce: u64) -> TransactionRequest
Sets the nonce for the transaction.
Sourcepub const fn max_fee_per_gas(self, max_fee_per_gas: u128) -> TransactionRequest
pub const fn max_fee_per_gas(self, max_fee_per_gas: u128) -> TransactionRequest
Sets the maximum fee per gas for the transaction.
Sourcepub const fn max_priority_fee_per_gas(
self,
max_priority_fee_per_gas: u128,
) -> TransactionRequest
pub const fn max_priority_fee_per_gas( self, max_priority_fee_per_gas: u128, ) -> TransactionRequest
Sets the maximum priority fee per gas for the transaction.
Sourcepub const fn to(self, to: Address) -> TransactionRequest
pub const fn to(self, to: Address) -> TransactionRequest
Sets the recipient address for the transaction.
Sourcepub const fn value(self, value: Uint<256, 4>) -> TransactionRequest
pub const fn value(self, value: Uint<256, 4>) -> TransactionRequest
Sets the value (amount) for the transaction.
Sourcepub fn access_list(self, access_list: AccessList) -> TransactionRequest
pub fn access_list(self, access_list: AccessList) -> TransactionRequest
Sets the access list for the transaction.
Sourcepub fn input(self, input: TransactionInput) -> TransactionRequest
pub fn input(self, input: TransactionInput) -> TransactionRequest
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
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-7702 if authorization_list is set
- 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.
NOTE: sidecar
must be present, even if blob_versioned_hashes
is set.
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_7702(&self) -> Result<(), Vec<&'static str>>
pub fn complete_7702(&self) -> Result<(), Vec<&'static str>>
Check if all necessary keys are present to build a 7702 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, TransactionRequest>
pub fn build_typed_tx(self) -> Result<TypedTransaction, TransactionRequest>
Build an TypedTransaction
In case Ok(...)
is returned, the TypedTransaction
is guaranteed to be complete, e.g.
sendable to the network.
Sourcepub fn build_consensus_tx(self) -> Result<TypedTransaction, BuildTransactionErr>
pub fn build_consensus_tx(self) -> Result<TypedTransaction, BuildTransactionErr>
Build an TypedTransaction
.
In case Ok(...)
is returned, the TypedTransaction
does not guarantee to be complete,
e.g. sendable to the network.
E.g. a particular case is when the transaction is of type Eip4844
and the sidecar
is not
set, in this case the transaction is not complete. It can still be used to calculate the
signature of the transaction though.
In case the requirement is to build a complete transaction, use build_typed_tx
instead.
Trait Implementations§
Source§impl<'arbitrary> Arbitrary<'arbitrary> for TransactionRequest
impl<'arbitrary> Arbitrary<'arbitrary> for TransactionRequest
Source§fn arbitrary(
u: &mut Unstructured<'arbitrary>,
) -> Result<TransactionRequest, Error>
fn arbitrary( u: &mut Unstructured<'arbitrary>, ) -> Result<TransactionRequest, Error>
Self
from the given unstructured data. Read moreSource§fn arbitrary_take_rest(
u: Unstructured<'arbitrary>,
) -> Result<TransactionRequest, Error>
fn arbitrary_take_rest( u: Unstructured<'arbitrary>, ) -> Result<TransactionRequest, Error>
Self
from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured
this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured
this type
needs to construct itself. Read moreSource§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<TransactionRequest, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<TransactionRequest, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<Transaction> for TransactionRequest
impl From<Transaction> for TransactionRequest
Source§fn from(tx: Transaction) -> TransactionRequest
fn from(tx: Transaction) -> TransactionRequest
Source§impl From<TxEip1559> for TransactionRequest
impl From<TxEip1559> for TransactionRequest
Source§fn from(tx: TxEip1559) -> TransactionRequest
fn from(tx: TxEip1559) -> TransactionRequest
Source§impl From<TxEip2930> for TransactionRequest
impl From<TxEip2930> for TransactionRequest
Source§fn from(tx: TxEip2930) -> TransactionRequest
fn from(tx: TxEip2930) -> TransactionRequest
Source§impl From<TxEip4844> for TransactionRequest
impl From<TxEip4844> for TransactionRequest
Source§fn from(tx: TxEip4844) -> TransactionRequest
fn from(tx: TxEip4844) -> TransactionRequest
Source§impl From<TxEip4844Variant> for TransactionRequest
impl From<TxEip4844Variant> for TransactionRequest
Source§fn from(tx: TxEip4844Variant) -> TransactionRequest
fn from(tx: TxEip4844Variant) -> TransactionRequest
Source§impl From<TxEip4844WithSidecar> for TransactionRequest
impl From<TxEip4844WithSidecar> for TransactionRequest
Source§fn from(tx: TxEip4844WithSidecar) -> TransactionRequest
fn from(tx: TxEip4844WithSidecar) -> TransactionRequest
Source§impl From<TxEip7702> for TransactionRequest
impl From<TxEip7702> for TransactionRequest
Source§fn from(tx: TxEip7702) -> TransactionRequest
fn from(tx: TxEip7702) -> TransactionRequest
Source§impl From<TxEnvelope> for TransactionRequest
impl From<TxEnvelope> for TransactionRequest
Source§fn from(envelope: TxEnvelope) -> TransactionRequest
fn from(envelope: TxEnvelope) -> TransactionRequest
Source§impl From<TxLegacy> for TransactionRequest
impl From<TxLegacy> for TransactionRequest
Source§fn from(tx: TxLegacy) -> TransactionRequest
fn from(tx: TxLegacy) -> TransactionRequest
Source§impl From<TypedTransaction> for TransactionRequest
impl From<TypedTransaction> for TransactionRequest
Source§fn from(tx: TypedTransaction) -> TransactionRequest
fn from(tx: TypedTransaction) -> TransactionRequest
Source§impl Hash for TransactionRequest
impl Hash for TransactionRequest
Source§impl PartialEq for TransactionRequest
impl PartialEq for TransactionRequest
Source§impl Serialize for TransactionRequest
impl Serialize for TransactionRequest
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl TransactionBuilder4844 for TransactionRequest
impl TransactionBuilder4844 for TransactionRequest
Source§fn max_fee_per_blob_gas(&self) -> Option<u128>
fn max_fee_per_blob_gas(&self) -> Option<u128>
Source§fn set_max_fee_per_blob_gas(&mut self, max_fee_per_blob_gas: u128)
fn set_max_fee_per_blob_gas(&mut self, max_fee_per_blob_gas: u128)
Source§fn blob_sidecar(&self) -> Option<&BlobTransactionSidecar>
fn blob_sidecar(&self) -> Option<&BlobTransactionSidecar>
Source§fn set_blob_sidecar(&mut self, sidecar: BlobTransactionSidecar)
fn set_blob_sidecar(&mut self, sidecar: BlobTransactionSidecar)
Source§fn with_max_fee_per_blob_gas(self, max_fee_per_blob_gas: u128) -> Self
fn with_max_fee_per_blob_gas(self, max_fee_per_blob_gas: u128) -> Self
Source§fn with_blob_sidecar(self, sidecar: BlobTransactionSidecar) -> Self
fn with_blob_sidecar(self, sidecar: BlobTransactionSidecar) -> Self
Source§impl TransactionBuilder7702 for TransactionRequest
impl TransactionBuilder7702 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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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 more