pub struct TxEnv {Show 14 fields
pub tx_type: u8,
pub caller: Address,
pub gas_limit: u64,
pub gas_price: u128,
pub kind: TxKind,
pub value: U256,
pub data: Bytes,
pub nonce: u64,
pub chain_id: Option<u64>,
pub access_list: AccessList,
pub gas_priority_fee: Option<u128>,
pub blob_hashes: Vec<B256>,
pub max_fee_per_blob_gas: u128,
pub authorization_list: Vec<Either<SignedAuthorization, RecoveredAuthorization>>,
}Expand description
The Transaction Environment is a struct that contains all fields that can be found in all Ethereum transaction,
including EIP-4844, EIP-7702, EIP-7873, etc. It implements the Transaction trait, which is used inside the EVM to execute a transaction.
TxEnvBuilder builder is recommended way to create a new TxEnv as it will automatically
set the transaction type based on the fields set.
Fields§
§tx_type: u8Transaction type
caller: AddressCaller aka Author aka transaction signer
gas_limit: u64The gas limit of the transaction.
gas_price: u128The gas price of the transaction.
For EIP-1559 transaction this represent max_gas_fee.
kind: TxKindThe destination of the transaction
value: U256The value sent to transact_to
data: BytesThe data of the transaction
nonce: u64The nonce of the transaction
chain_id: Option<u64>The chain ID of the transaction
Incorporated as part of the Spurious Dragon upgrade via EIP-155.
access_list: AccessListA list of addresses and storage keys that the transaction plans to access
Added in EIP-2930.
gas_priority_fee: Option<u128>The priority fee per gas
Incorporated as part of the London upgrade via EIP-1559.
blob_hashes: Vec<B256>The list of blob versioned hashes
Per EIP there should be at least one blob present if max_fee_per_blob_gas is Some.
Incorporated as part of the Cancun upgrade via EIP-4844.
max_fee_per_blob_gas: u128The max fee per blob gas
Incorporated as part of the Cancun upgrade via EIP-4844.
List of authorizations
authorization_list contains the signature that authorizes this
caller to place the code to signer account.
Set EOA account code for one transaction via EIP-7702.
Implementations§
Source§impl TxEnv
impl TxEnv
Sourcepub fn derive_tx_type(&mut self) -> Result<(), DeriveTxTypeError>
pub fn derive_tx_type(&mut self) -> Result<(), DeriveTxTypeError>
Derives tx type from transaction fields and sets it to tx_type.
Returns error in case some fields were not set correctly.
Insert a list of signed authorizations into the authorization list.
Insert a list of recovered authorizations into the authorization list.
Source§impl TxEnv
impl TxEnv
Sourcepub fn builder() -> TxEnvBuilder
pub fn builder() -> TxEnvBuilder
Create a new builder for constructing a TxEnv
Sourcepub fn builder_for_bench() -> TxEnvBuilder
pub fn builder_for_bench() -> TxEnvBuilder
Create a new builder for constructing a TxEnv with benchmark-specific values.
Sourcepub fn modify(self) -> TxEnvBuilder
pub fn modify(self) -> TxEnvBuilder
Modify the TxEnv by using builder pattern.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TxEnv
impl<'de> Deserialize<'de> for TxEnv
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 Transaction for TxEnv
impl Transaction for TxEnv
Source§type AccessListItem<'a> = &'a AccessListItem
type AccessListItem<'a> = &'a AccessListItem
Source§type Authorization<'a> = &'a Either<SignedAuthorization, RecoveredAuthorization>
type Authorization<'a> = &'a Either<SignedAuthorization, RecoveredAuthorization>
Source§fn gas_price(&self) -> u128
fn gas_price(&self) -> u128
Source§fn access_list(&self) -> Option<impl Iterator<Item = Self::AccessListItem<'_>>>
fn access_list(&self) -> Option<impl Iterator<Item = Self::AccessListItem<'_>>>
Source§fn max_fee_per_gas(&self) -> u128
fn max_fee_per_gas(&self) -> u128
Source§fn max_fee_per_blob_gas(&self) -> u128
fn max_fee_per_blob_gas(&self) -> u128
Source§fn blob_versioned_hashes(&self) -> &[B256] ⓘ
fn blob_versioned_hashes(&self) -> &[B256] ⓘ
Source§fn max_priority_fee_per_gas(&self) -> Option<u128>
fn max_priority_fee_per_gas(&self) -> Option<u128>
§fn total_blob_gas(&self) -> u64
fn total_blob_gas(&self) -> u64
§fn calc_max_data_fee(&self) -> Uint<256, 4>
fn calc_max_data_fee(&self) -> Uint<256, 4>
data_fee of the transaction. Read more§fn effective_gas_price(&self, base_fee: u128) -> u128
fn effective_gas_price(&self, base_fee: u128) -> u128
§fn max_balance_spending(&self) -> Result<Uint<256, 4>, InvalidTransaction>
fn max_balance_spending(&self) -> Result<Uint<256, 4>, InvalidTransaction>
§fn ensure_enough_balance(
&self,
balance: Uint<256, 4>,
) -> Result<(), InvalidTransaction>
fn ensure_enough_balance( &self, balance: Uint<256, 4>, ) -> Result<(), InvalidTransaction>
§fn effective_balance_spending(
&self,
base_fee: u128,
blob_price: u128,
) -> Result<Uint<256, 4>, InvalidTransaction>
fn effective_balance_spending( &self, base_fee: u128, blob_price: u128, ) -> Result<Uint<256, 4>, InvalidTransaction>
§fn gas_balance_spending(
&self,
base_fee: u128,
blob_price: u128,
) -> Result<Uint<256, 4>, InvalidTransaction>
fn gas_balance_spending( &self, base_fee: u128, blob_price: u128, ) -> Result<Uint<256, 4>, InvalidTransaction>
Self::effective_balance_spending but without the value. Read moreimpl Eq for TxEnv
impl StructuralPartialEq for TxEnv
Auto Trait Implementations§
impl !Freeze for TxEnv
impl RefUnwindSafe for TxEnv
impl Send for TxEnv
impl Sync for TxEnv
impl Unpin for TxEnv
impl UnwindSafe for TxEnv
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,
§impl<T> Conv for T
impl<T> Conv for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
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§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.