PodTransactionRequest

Struct PodTransactionRequest 

Source
pub struct PodTransactionRequest {
    pub inner: TransactionRequest,
}

Fields§

§inner: TransactionRequest

Methods from Deref<Target = TransactionRequest>§

Source

pub fn normalize_input(&mut self)

Ensures that if either input or data is set, the input field contains the value.

This removes data the data field.

Source

pub fn normalize_data(&mut self)

Ensures that if either data or input is set, the data field contains the value.

This removes input the data field.

Source

pub fn set_input_and_data(&mut self)

If only one field is set, this also sets the other field by with that value.

This is a noop if both fields are already set.

Source

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)

Source

pub fn has_eip4844_fields(&self) -> bool

Returns true if any of the EIP-4844 fields are set:

  • blob sidecar
  • blob versioned hashes
  • max fee per blob gas
Source

pub fn has_eip1559_fields(&self) -> bool

Returns true if any of the EIP-1559 fee fields are set:

  • max fee per gas
  • max priority fee per gas
Source

pub fn populate_blob_hashes(&mut self)

Populate the blob_versioned_hashes key, if a sidecar exists. No effect otherwise.

Source

pub fn get_invalid_common_fields(&self) -> Vec<&'static str>

Gets invalid fields for all transaction types

Source

pub fn get_invalid_1559_fields(&self) -> Vec<&'static str>

Gets invalid fields for EIP-1559 transaction type

Source

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.

Source

pub fn minimal_tx_type(&self) -> TxType

Returns the minimal transaction type this request can be converted into based on the fields that are set.

Compared to Self::preferred_type which is intended for building and eventually signing transactions and which prefers TxType::Eip1559 if no conflicting fields are set, this function is intended for deriving the minimal transaction type (legacy).

Self::minimal_tx_type is mostly relevant for the server-side, for example executing eth_calls against historic state (pre TxType::Eip1559) and is used to configure the EVM’s transaction environment with the minimal settings. Whereas Self::preferred_type is recommend for using client-side (filling a TransactionRequest and signing the transaction TransactionRequest::build_typed_tx).

The type is determined in the following order:

  • EIP-7702 if authorization_list is set
  • EIP-4844 if any EIP-4844 fields are set (sidecar, blob hashes, max blob fee)
  • EIP-1559 if any EIP-1559 fee fields are set (max fee per gas, max priority fee)
  • EIP-2930 if access_list is set
  • Legacy otherwise
§Examples
use alloy_consensus::TxType;
use alloy_eips::eip2930::AccessList;
use alloy_rpc_types_eth::TransactionRequest;

// EIP-7702 (highest priority)
let mut request = TransactionRequest::default();
request.authorization_list = Some(vec![]);
assert_eq!(request.minimal_tx_type(), TxType::Eip7702);

// EIP-4844 with max_fee_per_blob_gas
let request = TransactionRequest::default().max_fee_per_blob_gas(1000000000);
assert_eq!(request.minimal_tx_type(), TxType::Eip4844);

// EIP-1559 with max_fee_per_gas
let request = TransactionRequest::default().max_fee_per_gas(2000000000);
assert_eq!(request.minimal_tx_type(), TxType::Eip1559);

// EIP-1559 with max_priority_fee_per_gas
let request = TransactionRequest::default().max_priority_fee_per_gas(1000000000);
assert_eq!(request.minimal_tx_type(), TxType::Eip1559);

// EIP-2930 with access_list
let request = TransactionRequest::default().access_list(AccessList::default());
assert_eq!(request.minimal_tx_type(), TxType::Eip2930);

// Legacy (default fallback)
let request = TransactionRequest::default();
assert_eq!(request.minimal_tx_type(), TxType::Legacy);

// Priority example: EIP-4844 overrides EIP-1559
let mut request = TransactionRequest::default()
    .max_fee_per_gas(2000000000) // EIP-1559 (ignored)
    .max_fee_per_blob_gas(1000000000); // EIP-4844 (takes priority)
assert_eq!(request.minimal_tx_type(), TxType::Eip4844);
Source

pub fn preferred_type(&self) -> TxType

Check this builder’s preferred type, based on the fields that are set.

This function is intended for building and eventually signing transactions client-side. Unlike Self::minimal_tx_type which returns the minimal required type, this function prefers TxType::Eip1559 when no conflicting fields 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
§Examples
use alloy_consensus::TxType;
use alloy_eips::eip2930::AccessList;
use alloy_rpc_types_eth::TransactionRequest;

// EIP-7702 (highest priority)
let mut request = TransactionRequest::default();
request.authorization_list = Some(vec![]);
assert_eq!(request.preferred_type(), TxType::Eip7702);

// EIP-4844 with max_fee_per_blob_gas
let request = TransactionRequest::default().max_fee_per_blob_gas(1000000000);
assert_eq!(request.preferred_type(), TxType::Eip4844);

// EIP-2930 with both access_list and gas_price
let request =
    TransactionRequest::default().access_list(AccessList::default()).gas_price(20000000000);
assert_eq!(request.preferred_type(), TxType::Eip2930);

// Legacy with only gas_price (no access_list)
let request = TransactionRequest::default().gas_price(20000000000);
assert_eq!(request.preferred_type(), TxType::Legacy);

// EIP-1559 as default for modern transactions
let request = TransactionRequest::default();
assert_eq!(request.preferred_type(), TxType::Eip1559);

// EIP-1559 even with access_list but no gas_price
let request = TransactionRequest::default().access_list(AccessList::default());
assert_eq!(request.preferred_type(), TxType::Eip1559);
§Key Differences from Self::minimal_tx_type
use alloy_consensus::TxType;
use alloy_eips::eip2930::AccessList;
use alloy_rpc_types_eth::TransactionRequest;

// Empty request - preferred_type prefers EIP-1559, minimal_tx_type falls back to Legacy
let request = TransactionRequest::default();
assert_eq!(request.preferred_type(), TxType::Eip1559); // Preferred for new txs
assert_eq!(request.minimal_tx_type(), TxType::Legacy); // Minimal requirement

// Access list only - different behavior
let request = TransactionRequest::default().access_list(AccessList::default());
assert_eq!(request.preferred_type(), TxType::Eip1559); // Still prefers EIP-1559
assert_eq!(request.minimal_tx_type(), TxType::Eip2930); // Minimal is EIP-2930

// Gas price only - both agree on Legacy
let request = TransactionRequest::default().gas_price(20000000000);
assert_eq!(request.preferred_type(), TxType::Legacy);
assert_eq!(request.minimal_tx_type(), TxType::Legacy);
Source

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.
Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for PodTransactionRequest

Source§

fn clone(&self) -> PodTransactionRequest

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PodTransactionRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PodTransactionRequest

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Deref for PodTransactionRequest

Source§

type Target = TransactionRequest

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for PodTransactionRequest

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<'de> Deserialize<'de> for PodTransactionRequest

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<EthereumTxEnvelope<TxEip4844Variant>> for PodTransactionRequest

Source§

fn from(value: TxEnvelope) -> Self

Converts to this type from the input type.
Source§

impl From<EthereumTypedTransaction<TxEip4844Variant>> for PodTransactionRequest

Source§

fn from(value: TypedTransaction) -> Self

Converts to this type from the input type.
Source§

impl Serialize for PodTransactionRequest

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TransactionBuilder<PodNetwork> for PodTransactionRequest

Source§

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

Get the chain ID for the transaction.
Source§

fn set_chain_id(&mut self, chain_id: ChainId)

Set the chain ID for the transaction.
Source§

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

Get the nonce for the transaction.
Source§

fn set_nonce(&mut self, nonce: u64)

Set the nonce for the transaction.
Source§

fn take_nonce(&mut self) -> Option<u64>

Takes the nonce out of the transaction, clearing it.
Source§

fn input(&self) -> Option<&Bytes>

Get the input data for the transaction.
Source§

fn set_input<T: Into<Bytes>>(&mut self, input: T)

Set the input data for the transaction.
Source§

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

Get the sender for the transaction.
Source§

fn set_from(&mut self, from: Address)

Set the sender for the transaction.
Source§

fn kind(&self) -> Option<TxKind>

Get the kind of transaction.
Source§

fn clear_kind(&mut self)

Clear the kind of transaction.
Source§

fn set_kind(&mut self, kind: TxKind)

Set the kind of transaction.
Source§

fn value(&self) -> Option<U256>

Get the value for the transaction.
Source§

fn set_value(&mut self, value: U256)

Set the value for the transaction.
Source§

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

Get the legacy gas price for the transaction.
Source§

fn set_gas_price(&mut self, gas_price: u128)

Set the legacy gas price for the transaction.
Source§

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

Get the max fee per gas for the transaction.
Source§

fn set_max_fee_per_gas(&mut self, max_fee_per_gas: u128)

Set the max fee per gas for the transaction.
Source§

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

Get the max priority fee per gas for the transaction.
Source§

fn set_max_priority_fee_per_gas(&mut self, max_priority_fee_per_gas: u128)

Set the max priority fee per gas for the transaction.
Source§

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

Get the gas limit for the transaction.
Source§

fn set_gas_limit(&mut self, gas_limit: u64)

Set the gas limit for the transaction.
Source§

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

Get the EIP-2930 access list for the transaction.
Source§

fn set_access_list(&mut self, access_list: AccessList)

Sets the EIP-2930 access list.
Source§

fn complete_type(&self, ty: TxType) -> Result<(), Vec<&'static str>>

Check if all necessary keys are present to build the specified type, returning a list of missing keys.
Source§

fn can_submit(&self) -> bool

True if the builder contains all necessary information to be submitted to the eth_sendTransaction endpoint.
Source§

fn can_build(&self) -> bool

True if the builder contains all necessary information to be built into a valid transaction.
Source§

fn output_tx_type(&self) -> TxType

Returns the transaction type that this builder will attempt to build. This does not imply that the builder is ready to build.
Source§

fn output_tx_type_checked(&self) -> Option<TxType>

Returns the transaction type that this builder will build. None if the builder is not ready to build.
Source§

fn prep_for_submission(&mut self)

Trim any conflicting keys and populate any computed fields (like blob hashes). Read more
Source§

fn build_unsigned(self) -> BuildResult<TypedTransaction, PodNetwork>

Build an unsigned, but typed, transaction.
Source§

async fn build<W: NetworkWallet<PodNetwork>>( self, wallet: &W, ) -> Result<<PodNetwork as Network>::TxEnvelope, TransactionBuilderError<PodNetwork>>

Build a signed transaction.
Source§

fn with_chain_id(self, chain_id: u64) -> Self

Builder-pattern method for setting the chain ID.
Source§

fn with_nonce(self, nonce: u64) -> Self

Builder-pattern method for setting the nonce.
Source§

fn without_nonce(self) -> Self

Takes the nonce out of the transaction, clearing it.
Source§

fn with_input<T>(self, input: T) -> Self
where T: Into<Bytes>,

Builder-pattern method for setting the input data.
Source§

fn set_input_kind<T>(&mut self, input: T, _: TransactionInputKind)
where T: Into<Bytes>,

Set the input data for the transaction, respecting the input kind
Source§

fn with_input_kind<T>(self, input: T, kind: TransactionInputKind) -> Self
where T: Into<Bytes>,

Builder-pattern method for setting the input data, respecting the input kind
Source§

fn with_from(self, from: Address) -> Self

Builder-pattern method for setting the sender.
Source§

fn with_kind(self, kind: TxKind) -> Self

Builder-pattern method for setting the kind of transaction.
Source§

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

Get the recipient for the transaction.
Source§

fn set_to(&mut self, to: Address)

Set the recipient for the transaction.
Source§

fn with_to(self, to: Address) -> Self

Builder-pattern method for setting the recipient.
Source§

fn set_create(&mut self)

Set the to field to a create call.
Source§

fn into_create(self) -> Self

Set the to field to a create call.
Source§

fn set_deploy_code<T>(&mut self, code: T)
where T: Into<Bytes>,

Deploy the code by making a create call with data. This will set the to field to TxKind::Create.
Source§

fn with_deploy_code<T>(self, code: T) -> Self
where T: Into<Bytes>,

Deploy the code by making a create call with data. This will set the to field to TxKind::Create.
Source§

fn set_call<T>(&mut self, t: &T)
where T: SolCall,

Set the data field to a contract call. This will clear the to field if it is set to TxKind::Create.
Source§

fn with_call<T>(self, t: &T) -> Self
where T: SolCall,

Make a contract call with data.
Source§

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

Calculates the address that will be created by the transaction, if any. Read more
Source§

fn with_value(self, value: Uint<256, 4>) -> Self

Builder-pattern method for setting the value.
Source§

fn with_gas_price(self, gas_price: u128) -> Self

Builder-pattern method for setting the legacy gas price.
Source§

fn with_max_fee_per_gas(self, max_fee_per_gas: u128) -> Self

Builder-pattern method for setting max fee per gas .
Source§

fn with_max_priority_fee_per_gas(self, max_priority_fee_per_gas: u128) -> Self

Builder-pattern method for setting max priority fee per gas.
Source§

fn with_gas_limit(self, gas_limit: u64) -> Self

Builder-pattern method for setting the gas limit.
Source§

fn with_access_list(self, access_list: AccessList) -> Self

Builder-pattern method for setting the access list.
Source§

fn complete_preferred(&self) -> Result<(), Vec<&'static str>>

Check if all necessary keys are present to build the currently-preferred transaction type, returning a list of missing keys.
Source§

fn assert_preferred(&self, ty: <N as Network>::TxType)

Assert that the builder prefers a certain transaction type. This does not indicate that the builder is ready to build. This function uses a dbg_assert_eq! to check the builder status, and will have no affect in release builds.
Source§

fn assert_preferred_chained(self, ty: <N as Network>::TxType) -> Self

Assert that the builder prefers a certain transaction type. This does not indicate that the builder is ready to build. This function uses a dbg_assert_eq! to check the builder status, and will have no affect in release builds.
Source§

fn apply<F>(self, f: F) -> Self
where F: FnOnce(Self) -> Self,

Apply a function to the builder, returning the modified builder.
Source§

fn try_apply<F, E>(self, f: F) -> Result<Self, E>
where F: FnOnce(Self) -> Result<Self, E>,

Apply a fallible function to the builder, returning the modified builder or an error.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<'de, T> BorrowedRpcObject<'de> for T
where T: RpcBorrow<'de> + RpcSend,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<'de, T> RpcBorrow<'de> for T
where T: Deserialize<'de> + Debug + Send + Sync + Unpin,

Source§

impl<T> RpcObject for T
where T: RpcSend + RpcRecv,

Source§

impl<T> RpcRecv for T
where T: DeserializeOwned + Debug + Send + Sync + Unpin + 'static,

Source§

impl<T> RpcSend for T
where T: Serialize + Clone + Debug + Send + Sync + Unpin,