revm_context_interface::transaction

Trait Transaction

Source
pub trait Transaction {
Show 20 methods // Required methods fn tx_type(&self) -> u8; fn caller(&self) -> Address; fn gas_limit(&self) -> u64; fn value(&self) -> U256; fn input(&self) -> &Bytes; fn nonce(&self) -> u64; fn kind(&self) -> TxKind; fn chain_id(&self) -> Option<u64>; fn gas_price(&self) -> u128; fn access_list(&self) -> Option<impl Iterator<Item = (&Address, &[B256])>>; fn blob_versioned_hashes(&self) -> &[B256]; fn max_fee_per_blob_gas(&self) -> u128; fn authorization_list_len(&self) -> usize; fn authorization_list(&self) -> impl Iterator<Item = AuthorizationItem>; fn max_priority_fee_per_gas(&self) -> Option<u128>; // Provided methods fn access_list_nums(&self) -> Option<(usize, usize)> { ... } fn total_blob_gas(&self) -> u64 { ... } fn calc_max_data_fee(&self) -> U256 { ... } fn max_fee_per_gas(&self) -> u128 { ... } fn effective_gas_price(&self, base_fee: u128) -> u128 { ... }
}
Expand description

Main Transaction trait that abstracts and specifies all transaction currently supported by Ethereum

Access to any associated type is gaited behind tx_type function.

It can be extended to support new transaction types and only transaction types can be deprecated by not returning tx_type.

Required Methods§

Source

fn tx_type(&self) -> u8

Returns the transaction type.

Depending on this field other functions should be called.

Source

fn caller(&self) -> Address

Caller aka Author aka transaction signer.

Note : Common field for all transactions.

Source

fn gas_limit(&self) -> u64

The maximum amount of gas the transaction can use.

Note : Common field for all transactions.

Source

fn value(&self) -> U256

The value sent to the receiver of [TxKind::Call][primitives::TxKind::Call].

Note : Common field for all transactions.

Source

fn input(&self) -> &Bytes

Returns the input data of the transaction.

Note : Common field for all transactions.

Source

fn nonce(&self) -> u64

The nonce of the transaction.

Note : Common field for all transactions.

Source

fn kind(&self) -> TxKind

Transaction kind. It can be Call or Create.

Kind is applicable for: Legacy, EIP-2930, EIP-1559 And is Call for EIP-4844 and EIP-7702 transactions.

Source

fn chain_id(&self) -> Option<u64>

Chain Id is optional for legacy transactions.

As it was introduced in EIP-155.

Source

fn gas_price(&self) -> u128

Gas price for the transaction. It is only applicable for Legacy and EIP-2930 transactions. For Eip1559 it is max_fee_per_gas.

Source

fn access_list(&self) -> Option<impl Iterator<Item = (&Address, &[B256])>>

Source

fn blob_versioned_hashes(&self) -> &[B256]

Returns vector of fixed size hash(32 bytes)

Note : EIP-4844 transaction field.

Source

fn max_fee_per_blob_gas(&self) -> u128

Max fee per data gas

Note : EIP-4844 transaction field.

Source

fn authorization_list_len(&self) -> usize

Returns length of the authorization list.

§Note

Transaction is considered invalid if list is empty.

Source

fn authorization_list(&self) -> impl Iterator<Item = AuthorizationItem>

List of authorizations, that contains the signature that authorizes this caller to place the code to signer account.

Set EOA account code for one transaction

EIP-Set EOA account code for one transaction

Source

fn max_priority_fee_per_gas(&self) -> Option<u128>

Maximum priority fee per gas.

Provided Methods§

Source

fn access_list_nums(&self) -> Option<(usize, usize)>

Source

fn total_blob_gas(&self) -> u64

Total gas for all blobs. Max number of blocks is already checked so we dont need to check for overflow.

TODO remove this

Source

fn calc_max_data_fee(&self) -> U256

Calculates the maximum [EIP-4844] data_fee of the transaction.

This is used for ensuring that the user has at least enough funds to pay the max_fee_per_blob_gas * total_blob_gas, on top of regular gas costs.

See EIP-4844: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4844.md#execution-layer-validation

TODO remove it, make a utility trait.

Source

fn max_fee_per_gas(&self) -> u128

Returns maximum fee that can be paid for the transaction.

Source

fn effective_gas_price(&self, base_fee: u128) -> u128

Returns effective gas price is gas price field for Legacy and Eip2930 transaction.

While for transactions after Eip1559 it is minimum of max_fee and base + max_priority_fee.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'a, T: 'a + Transaction + ?Sized> Transaction for &'a T

Source§

fn tx_type(&self) -> u8

Source§

fn caller(&self) -> Address

Source§

fn gas_limit(&self) -> u64

Source§

fn value(&self) -> U256

Source§

fn input(&self) -> &Bytes

Source§

fn nonce(&self) -> u64

Source§

fn kind(&self) -> TxKind

Source§

fn chain_id(&self) -> Option<u64>

Source§

fn gas_price(&self) -> u128

Source§

fn access_list(&self) -> Option<impl Iterator<Item = (&Address, &[B256])>>

Source§

fn access_list_nums(&self) -> Option<(usize, usize)>

Source§

fn blob_versioned_hashes(&self) -> &[B256]

Source§

fn max_fee_per_blob_gas(&self) -> u128

Source§

fn total_blob_gas(&self) -> u64

Source§

fn calc_max_data_fee(&self) -> U256

Source§

fn authorization_list_len(&self) -> usize

Source§

fn authorization_list(&self) -> impl Iterator<Item = AuthorizationItem>

Source§

fn max_fee_per_gas(&self) -> u128

Source§

fn max_priority_fee_per_gas(&self) -> Option<u128>

Source§

fn effective_gas_price(&self, base_fee: u128) -> u128

Source§

impl<T: Transaction + ?Sized> Transaction for Box<T>

Source§

fn tx_type(&self) -> u8

Source§

fn caller(&self) -> Address

Source§

fn gas_limit(&self) -> u64

Source§

fn value(&self) -> U256

Source§

fn input(&self) -> &Bytes

Source§

fn nonce(&self) -> u64

Source§

fn kind(&self) -> TxKind

Source§

fn chain_id(&self) -> Option<u64>

Source§

fn gas_price(&self) -> u128

Source§

fn access_list(&self) -> Option<impl Iterator<Item = (&Address, &[B256])>>

Source§

fn access_list_nums(&self) -> Option<(usize, usize)>

Source§

fn blob_versioned_hashes(&self) -> &[B256]

Source§

fn max_fee_per_blob_gas(&self) -> u128

Source§

fn total_blob_gas(&self) -> u64

Source§

fn calc_max_data_fee(&self) -> U256

Source§

fn authorization_list_len(&self) -> usize

Source§

fn authorization_list(&self) -> impl Iterator<Item = AuthorizationItem>

Source§

fn max_fee_per_gas(&self) -> u128

Source§

fn max_priority_fee_per_gas(&self) -> Option<u128>

Source§

fn effective_gas_price(&self, base_fee: u128) -> u128

Source§

impl<T: Transaction + ?Sized> Transaction for Rc<T>

Source§

fn tx_type(&self) -> u8

Source§

fn caller(&self) -> Address

Source§

fn gas_limit(&self) -> u64

Source§

fn value(&self) -> U256

Source§

fn input(&self) -> &Bytes

Source§

fn nonce(&self) -> u64

Source§

fn kind(&self) -> TxKind

Source§

fn chain_id(&self) -> Option<u64>

Source§

fn gas_price(&self) -> u128

Source§

fn access_list(&self) -> Option<impl Iterator<Item = (&Address, &[B256])>>

Source§

fn access_list_nums(&self) -> Option<(usize, usize)>

Source§

fn blob_versioned_hashes(&self) -> &[B256]

Source§

fn max_fee_per_blob_gas(&self) -> u128

Source§

fn total_blob_gas(&self) -> u64

Source§

fn calc_max_data_fee(&self) -> U256

Source§

fn authorization_list_len(&self) -> usize

Source§

fn authorization_list(&self) -> impl Iterator<Item = AuthorizationItem>

Source§

fn max_fee_per_gas(&self) -> u128

Source§

fn max_priority_fee_per_gas(&self) -> Option<u128>

Source§

fn effective_gas_price(&self, base_fee: u128) -> u128

Source§

impl<T: Transaction + ?Sized> Transaction for Arc<T>

Source§

fn tx_type(&self) -> u8

Source§

fn caller(&self) -> Address

Source§

fn gas_limit(&self) -> u64

Source§

fn value(&self) -> U256

Source§

fn input(&self) -> &Bytes

Source§

fn nonce(&self) -> u64

Source§

fn kind(&self) -> TxKind

Source§

fn chain_id(&self) -> Option<u64>

Source§

fn gas_price(&self) -> u128

Source§

fn access_list(&self) -> Option<impl Iterator<Item = (&Address, &[B256])>>

Source§

fn access_list_nums(&self) -> Option<(usize, usize)>

Source§

fn blob_versioned_hashes(&self) -> &[B256]

Source§

fn max_fee_per_blob_gas(&self) -> u128

Source§

fn total_blob_gas(&self) -> u64

Source§

fn calc_max_data_fee(&self) -> U256

Source§

fn authorization_list_len(&self) -> usize

Source§

fn authorization_list(&self) -> impl Iterator<Item = AuthorizationItem>

Source§

fn max_fee_per_gas(&self) -> u128

Source§

fn max_priority_fee_per_gas(&self) -> Option<u128>

Source§

fn effective_gas_price(&self, base_fee: u128) -> u128

Implementors§