Skip to main content

TransactionTrait

Trait TransactionTrait 

pub trait TransactionTrait:
    Typed2718
    + Debug
    + Any
    + Send
    + Sync
    + 'static {
Show 23 methods // Required methods fn chain_id(&self) -> Option<u64>; fn nonce(&self) -> u64; fn gas_limit(&self) -> u64; fn gas_price(&self) -> Option<u128>; fn max_fee_per_gas(&self) -> u128; fn max_priority_fee_per_gas(&self) -> Option<u128>; fn max_fee_per_blob_gas(&self) -> Option<u128>; fn priority_fee_or_price(&self) -> u128; fn effective_gas_price(&self, base_fee: Option<u64>) -> u128; fn is_dynamic_fee(&self) -> bool; fn kind(&self) -> TxKind; fn is_create(&self) -> bool; fn value(&self) -> Uint<256, 4>; fn input(&self) -> &Bytes; fn access_list(&self) -> Option<&AccessList>; fn blob_versioned_hashes(&self) -> Option<&[FixedBytes<32>]>; fn authorization_list(&self) -> Option<&[SignedAuthorization]>; // Provided methods fn effective_tip_per_gas(&self, base_fee: u64) -> Option<u128> { ... } fn to(&self) -> Option<Address> { ... } fn function_selector(&self) -> Option<&FixedBytes<4>> { ... } fn blob_count(&self) -> Option<u64> { ... } fn blob_gas_used(&self) -> Option<u64> { ... } fn authorization_count(&self) -> Option<u64> { ... }
}
Available on crate feature rpc only.
Expand description

Represents a minimal EVM transaction. Currently, EIP-1559, EIP-4844, and EIP-7702 support dynamic fees. We call these transactions “dynamic fee transactions”. We call non dynamic fee transactions(EIP-155, EIP-2930) “legacy fee transactions”.

Required Methods§

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

Get chain_id.

fn nonce(&self) -> u64

Get nonce.

fn gas_limit(&self) -> u64

Get gas_limit.

Under EIP-8037 this single limit funds both execution and state gas via the reservoir model.

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

Get gas_price.

fn max_fee_per_gas(&self) -> u128

For dynamic fee transactions returns the maximum fee per gas the caller is willing to pay.

For legacy fee transactions this is gas_price.

This is also commonly referred to as the “Gas Fee Cap”.

[TxEip8141] derives a compatibility estimate from its shared total fee budget; it has no signed per-gas fee cap. See that type’s documentation for pricing limits.

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

For dynamic fee transactions returns the maximum priority fee per gas the caller is willing to pay to the block author.

This will return None for legacy fee transactions

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

Max fee per blob gas for EIP-4844 transaction.

Returns None for non-eip4844 transactions.

This is also commonly referred to as the “Blob Gas Fee Cap”.

fn priority_fee_or_price(&self) -> u128

Return the max priority fee per gas if the transaction is a dynamic fee transaction, and otherwise return the gas price.

§Warning

This is different than the max_priority_fee_per_gas method, which returns None for legacy fee transactions.

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

Returns the effective gas price for the given base fee.

If the transaction is a legacy fee transaction, the gas price is returned.

Implementations with shared fee budgets, such as [TxEip8141], can only provide a compatibility estimate here. This interface has no blob base fee or charged gas input; it does not in general determine protocol GASPRICE or a realized receipt price.

fn is_dynamic_fee(&self) -> bool

Returns true if the transaction supports dynamic fees.

fn kind(&self) -> TxKind

Returns the transaction kind.

fn is_create(&self) -> bool

Returns true if the transaction is a contract creation. We don’t provide a default implementation via kind as it copies the 21-byte [TxKind] for this simple check. A proper implementation shouldn’t allocate.

fn value(&self) -> Uint<256, 4>

Get value.

fn input(&self) -> &Bytes

Get data.

fn access_list(&self) -> Option<&AccessList>

Returns the EIP-2930 access_list for the particular transaction type. Returns None for older transaction types.

fn blob_versioned_hashes(&self) -> Option<&[FixedBytes<32>]>

Blob versioned hashes for eip4844 transaction. For previous transaction types this is None.

fn authorization_list(&self) -> Option<&[SignedAuthorization]>

Returns the SignedAuthorization list of the transaction.

Returns None if this transaction is not EIP-7702.

Provided Methods§

fn effective_tip_per_gas(&self, base_fee: u64) -> Option<u128>

Returns the effective tip for this transaction.

For dynamic fee transactions: min(max_fee_per_gas - base_fee, max_priority_fee_per_gas). For legacy fee transactions: gas_price - base_fee.

Returns None if the per-gas cap is below the base fee. For [TxEip8141] this is a compatibility estimate ignoring blob charges and settlement gas usage; Some does not establish affordability of the shared budget at the block’s base fees.

fn to(&self) -> Option<Address>

Get the transaction’s address of the contract that will be called, or the address that will receive the transfer.

Returns None if this is a CREATE transaction.

fn function_selector(&self) -> Option<&FixedBytes<4>>

Returns the first 4bytes of the calldata for a function call.

The selector specifies the function to be called.

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

Returns the number of blobs of this transaction.

This is convenience function for len(blob_versioned_hashes).

Returns None for non-eip4844 transactions.

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

Returns the total gas for all blobs in this transaction.

Returns None for non-eip4844 transactions.

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

Returns the number of SignedAuthorizations in this transactions

This is convenience function for len(authorization_list).

Returns None for non-eip7702 transactions.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

§

impl Transaction for AnyRpcTransaction

§

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

§

fn nonce(&self) -> u64

§

fn gas_limit(&self) -> u64

§

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

§

fn max_fee_per_gas(&self) -> u128

§

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

§

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

§

fn priority_fee_or_price(&self) -> u128

§

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

§

fn effective_tip_per_gas(&self, base_fee: u64) -> Option<u128>

§

fn is_dynamic_fee(&self) -> bool

§

fn kind(&self) -> TxKind

§

fn is_create(&self) -> bool

§

fn to(&self) -> Option<Address>

§

fn value(&self) -> Uint<256, 4>

§

fn input(&self) -> &Bytes

§

fn function_selector(&self) -> Option<&FixedBytes<4>>

§

fn access_list(&self) -> Option<&AccessList>

§

fn blob_versioned_hashes(&self) -> Option<&[FixedBytes<32>]>

§

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

§

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

§

fn authorization_list(&self) -> Option<&[SignedAuthorization]>

§

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

§

impl Transaction for AnyTxEnvelope

§

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

§

fn nonce(&self) -> u64

§

fn gas_limit(&self) -> u64

§

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

§

fn max_fee_per_gas(&self) -> u128

§

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

§

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

§

fn priority_fee_or_price(&self) -> u128

§

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

§

fn effective_tip_per_gas(&self, base_fee: u64) -> Option<u128>

§

fn is_dynamic_fee(&self) -> bool

§

fn kind(&self) -> TxKind

§

fn is_create(&self) -> bool

§

fn to(&self) -> Option<Address>

§

fn value(&self) -> Uint<256, 4>

§

fn input(&self) -> &Bytes

§

fn function_selector(&self) -> Option<&FixedBytes<4>>

§

fn access_list(&self) -> Option<&AccessList>

§

fn blob_versioned_hashes(&self) -> Option<&[FixedBytes<32>]>

§

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

§

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

§

fn authorization_list(&self) -> Option<&[SignedAuthorization]>

§

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

§

impl Transaction for AnyTypedTransaction

§

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

§

fn nonce(&self) -> u64

§

fn gas_limit(&self) -> u64

§

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

§

fn max_fee_per_gas(&self) -> u128

§

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

§

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

§

fn priority_fee_or_price(&self) -> u128

§

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

§

fn effective_tip_per_gas(&self, base_fee: u64) -> Option<u128>

§

fn is_dynamic_fee(&self) -> bool

§

fn kind(&self) -> TxKind

§

fn is_create(&self) -> bool

§

fn to(&self) -> Option<Address>

§

fn value(&self) -> Uint<256, 4>

§

fn input(&self) -> &Bytes

§

fn function_selector(&self) -> Option<&FixedBytes<4>>

§

fn access_list(&self) -> Option<&AccessList>

§

fn blob_versioned_hashes(&self) -> Option<&[FixedBytes<32>]>

§

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

§

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

§

fn authorization_list(&self) -> Option<&[SignedAuthorization]>

§

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

§

impl Transaction for LazyTxEip7702

§

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

§

fn nonce(&self) -> u64

§

fn gas_limit(&self) -> u64

§

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

§

fn max_fee_per_gas(&self) -> u128

§

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

§

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

§

fn priority_fee_or_price(&self) -> u128

§

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

§

fn is_dynamic_fee(&self) -> bool

§

fn kind(&self) -> TxKind

§

fn is_create(&self) -> bool

§

fn value(&self) -> Uint<256, 4>

§

fn input(&self) -> &Bytes

§

fn access_list(&self) -> Option<&AccessList>

§

fn blob_versioned_hashes(&self) -> Option<&[FixedBytes<32>]>

§

fn authorization_list(&self) -> Option<&[SignedAuthorization]>

Source§

impl Transaction for MockTransaction

§

impl Transaction for TxEnvelope

§

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

§

fn nonce(&self) -> u64

§

fn gas_limit(&self) -> u64

§

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

§

fn max_fee_per_gas(&self) -> u128

§

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

§

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

§

fn priority_fee_or_price(&self) -> u128

§

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

§

fn is_dynamic_fee(&self) -> bool

§

fn kind(&self) -> TxKind

§

fn is_create(&self) -> bool

§

fn value(&self) -> Uint<256, 4>

§

fn input(&self) -> &Bytes

§

fn access_list(&self) -> Option<&AccessList>

§

fn blob_versioned_hashes(&self) -> Option<&[FixedBytes<32>]>

§

fn authorization_list(&self) -> Option<&[SignedAuthorization]>

§

impl Transaction for UnknownTxEnvelope

§

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

§

fn nonce(&self) -> u64

§

fn gas_limit(&self) -> u64

§

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

§

fn max_fee_per_gas(&self) -> u128

§

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

§

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

§

fn priority_fee_or_price(&self) -> u128

§

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

§

fn effective_tip_per_gas(&self, base_fee: u64) -> Option<u128>

§

fn is_dynamic_fee(&self) -> bool

§

fn kind(&self) -> TxKind

§

fn is_create(&self) -> bool

§

fn to(&self) -> Option<Address>

§

fn value(&self) -> Uint<256, 4>

§

fn input(&self) -> &Bytes

§

fn function_selector(&self) -> Option<&FixedBytes<4>>

§

fn access_list(&self) -> Option<&AccessList>

§

fn blob_versioned_hashes(&self) -> Option<&[FixedBytes<32>]>

§

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

§

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

§

fn authorization_list(&self) -> Option<&[SignedAuthorization]>

§

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

§

impl Transaction for UnknownTypedTransaction

§

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

§

fn nonce(&self) -> u64

§

fn gas_limit(&self) -> u64

§

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

§

fn max_fee_per_gas(&self) -> u128

§

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

§

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

§

fn priority_fee_or_price(&self) -> u128

§

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

§

fn is_dynamic_fee(&self) -> bool

§

fn kind(&self) -> TxKind

§

fn is_create(&self) -> bool

§

fn value(&self) -> Uint<256, 4>

§

fn input(&self) -> &Bytes

§

fn access_list(&self) -> Option<&AccessList>

§

fn blob_versioned_hashes(&self) -> Option<&[FixedBytes<32>]>

§

fn authorization_list(&self) -> Option<&[SignedAuthorization]>

§

impl<'a, T> Transaction for &'a T
where T: 'a + Transaction + ?Sized, &'a T: Typed2718 + Debug + Any + Send + Sync + 'static,

§

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

§

fn nonce(&self) -> u64

§

fn gas_limit(&self) -> u64

§

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

§

fn max_fee_per_gas(&self) -> u128

§

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

§

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

§

fn priority_fee_or_price(&self) -> u128

§

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

§

fn effective_tip_per_gas(&self, base_fee: u64) -> Option<u128>

§

fn is_dynamic_fee(&self) -> bool

§

fn kind(&self) -> TxKind

§

fn is_create(&self) -> bool

§

fn to(&self) -> Option<Address>

§

fn value(&self) -> Uint<256, 4>

§

fn input(&self) -> &Bytes

§

fn function_selector(&self) -> Option<&FixedBytes<4>>

§

fn access_list(&self) -> Option<&AccessList>

§

fn blob_versioned_hashes(&self) -> Option<&[FixedBytes<32>]>

§

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

§

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

§

fn authorization_list(&self) -> Option<&[SignedAuthorization]>

§

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

§

impl<L, R> Transaction for Either<L, R>
where L: Transaction, R: Transaction,

§

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

§

fn nonce(&self) -> u64

§

fn gas_limit(&self) -> u64

§

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

§

fn max_fee_per_gas(&self) -> u128

§

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

§

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

§

fn priority_fee_or_price(&self) -> u128

§

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

§

fn effective_tip_per_gas(&self, base_fee: u64) -> Option<u128>

§

fn is_dynamic_fee(&self) -> bool

§

fn kind(&self) -> TxKind

§

fn is_create(&self) -> bool

§

fn to(&self) -> Option<Address>

§

fn value(&self) -> Uint<256, 4>

§

fn input(&self) -> &Bytes

§

fn function_selector(&self) -> Option<&FixedBytes<4>>

§

fn access_list(&self) -> Option<&AccessList>

§

fn blob_versioned_hashes(&self) -> Option<&[FixedBytes<32>]>

§

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

§

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

§

fn authorization_list(&self) -> Option<&[SignedAuthorization]>

§

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

§

impl<T> Transaction for Arc<T>
where T: Transaction + ?Sized, Arc<T>: Typed2718 + Debug + Any + Send + Sync + 'static,

§

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

§

fn nonce(&self) -> u64

§

fn gas_limit(&self) -> u64

§

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

§

fn max_fee_per_gas(&self) -> u128

§

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

§

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

§

fn priority_fee_or_price(&self) -> u128

§

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

§

fn effective_tip_per_gas(&self, base_fee: u64) -> Option<u128>

§

fn is_dynamic_fee(&self) -> bool

§

fn kind(&self) -> TxKind

§

fn is_create(&self) -> bool

§

fn to(&self) -> Option<Address>

§

fn value(&self) -> Uint<256, 4>

§

fn input(&self) -> &Bytes

§

fn function_selector(&self) -> Option<&FixedBytes<4>>

§

fn access_list(&self) -> Option<&AccessList>

§

fn blob_versioned_hashes(&self) -> Option<&[FixedBytes<32>]>

§

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

§

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

§

fn authorization_list(&self) -> Option<&[SignedAuthorization]>

§

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

Source§

impl<T> Transaction for EthPooledTransaction<T>
where T: Transaction,

§

impl<T> Transaction for Sealed<T>
where T: Transaction,

§

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

§

fn nonce(&self) -> u64

§

fn gas_limit(&self) -> u64

§

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

§

fn max_fee_per_gas(&self) -> u128

§

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

§

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

§

fn priority_fee_or_price(&self) -> u128

§

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

§

fn effective_tip_per_gas(&self, base_fee: u64) -> Option<u128>

§

fn is_dynamic_fee(&self) -> bool

§

fn kind(&self) -> TxKind

§

fn is_create(&self) -> bool

§

fn to(&self) -> Option<Address>

§

fn value(&self) -> Uint<256, 4>

§

fn input(&self) -> &Bytes

§

fn function_selector(&self) -> Option<&FixedBytes<4>>

§

fn access_list(&self) -> Option<&AccessList>

§

fn blob_versioned_hashes(&self) -> Option<&[FixedBytes<32>]>

§

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

§

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

§

fn authorization_list(&self) -> Option<&[SignedAuthorization]>

§

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

§

impl<T> Transaction for WithOtherFields<T>
where T: Transaction,

Available on crate feature serde only.
§

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

§

fn nonce(&self) -> u64

§

fn gas_limit(&self) -> u64

§

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

§

fn max_fee_per_gas(&self) -> u128

§

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

§

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

§

fn priority_fee_or_price(&self) -> u128

§

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

§

fn effective_tip_per_gas(&self, base_fee: u64) -> Option<u128>

§

fn is_dynamic_fee(&self) -> bool

§

fn kind(&self) -> TxKind

§

fn is_create(&self) -> bool

§

fn to(&self) -> Option<Address>

§

fn value(&self) -> Uint<256, 4>

§

fn input(&self) -> &Bytes

§

fn function_selector(&self) -> Option<&FixedBytes<4>>

§

fn access_list(&self) -> Option<&AccessList>

§

fn blob_versioned_hashes(&self) -> Option<&[FixedBytes<32>]>

§

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

§

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

§

fn authorization_list(&self) -> Option<&[SignedAuthorization]>

§

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

Implementors§

§

impl Transaction for TxEip1559

§

impl Transaction for TxEip2930

§

impl Transaction for TxEip4844

§

impl Transaction for TxEip7702

§

impl Transaction for TxEip8141

§

impl Transaction for TxLegacy

§

impl<B, T> Transaction for Extended<B, T>
where B: Transaction, T: Transaction,

§

impl<Eip4844> Transaction for EthereumTxEnvelope<Eip4844>
where EthereumTxEnvelope<Eip4844>: Debug, Signed<TxLegacy>: Transaction, Signed<TxEip2930>: Transaction, Signed<TxEip1559>: Transaction, Signed<Eip4844>: Transaction, Signed<TxEip7702>: Transaction,

§

impl<Eip4844> Transaction for EthereumTypedTransaction<Eip4844>
where EthereumTypedTransaction<Eip4844>: Debug, TxLegacy: Transaction, TxEip2930: Transaction, TxEip1559: Transaction, Eip4844: Transaction, TxEip7702: Transaction,

§

impl<T, Sig> Transaction for Signed<T, Sig>
where T: Transaction, Sig: Debug + Send + Sync + 'static,

§

impl<T> Transaction for Transaction<T>
where T: Transaction,

§

impl<T> Transaction for TxEip4844Variant<T>
where T: Debug + Send + Sync + 'static,

§

impl<T> Transaction for TxEip4844WithSidecar<T>
where T: Debug + Send + Sync + 'static,