pub struct PodTransactionRequest {
pub inner: TransactionRequest,
}
Fields§
§inner: TransactionRequest
Methods from Deref<Target = TransactionRequest>§
Sourcepub fn normalize_input(&mut self)
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.
Sourcepub fn normalize_data(&mut self)
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.
Sourcepub fn set_input_and_data(&mut self)
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.
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 has_eip4844_fields(&self) -> bool
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
Sourcepub fn has_eip1559_fields(&self) -> bool
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
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 fn minimal_tx_type(&self) -> TxType
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);
Sourcepub fn preferred_type(&self) -> TxType
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);
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.
Trait Implementations§
Source§impl Clone for PodTransactionRequest
impl Clone for PodTransactionRequest
Source§fn clone(&self) -> PodTransactionRequest
fn clone(&self) -> PodTransactionRequest
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for PodTransactionRequest
impl Debug for PodTransactionRequest
Source§impl Default for PodTransactionRequest
impl Default for PodTransactionRequest
Source§impl Deref for PodTransactionRequest
impl Deref for PodTransactionRequest
Source§impl DerefMut for PodTransactionRequest
impl DerefMut for PodTransactionRequest
Source§impl<'de> Deserialize<'de> for PodTransactionRequest
impl<'de> Deserialize<'de> for PodTransactionRequest
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 From<EthereumTxEnvelope<TxEip4844Variant>> for PodTransactionRequest
impl From<EthereumTxEnvelope<TxEip4844Variant>> for PodTransactionRequest
Source§fn from(value: TxEnvelope) -> Self
fn from(value: TxEnvelope) -> Self
Source§impl From<EthereumTypedTransaction<TxEip4844Variant>> for PodTransactionRequest
impl From<EthereumTypedTransaction<TxEip4844Variant>> for PodTransactionRequest
Source§fn from(value: TypedTransaction) -> Self
fn from(value: TypedTransaction) -> Self
Source§impl Serialize for PodTransactionRequest
impl Serialize for PodTransactionRequest
Source§impl TransactionBuilder<PodNetwork> for PodTransactionRequest
impl TransactionBuilder<PodNetwork> for PodTransactionRequest
Source§fn set_chain_id(&mut self, chain_id: ChainId)
fn set_chain_id(&mut self, chain_id: ChainId)
Source§fn take_nonce(&mut self) -> Option<u64>
fn take_nonce(&mut self) -> Option<u64>
Source§fn clear_kind(&mut self)
fn clear_kind(&mut self)
Source§fn set_gas_price(&mut self, gas_price: u128)
fn set_gas_price(&mut self, gas_price: u128)
Source§fn max_fee_per_gas(&self) -> Option<u128>
fn max_fee_per_gas(&self) -> Option<u128>
Source§fn set_max_fee_per_gas(&mut self, max_fee_per_gas: u128)
fn set_max_fee_per_gas(&mut self, max_fee_per_gas: u128)
Source§fn max_priority_fee_per_gas(&self) -> Option<u128>
fn max_priority_fee_per_gas(&self) -> Option<u128>
Source§fn set_max_priority_fee_per_gas(&mut self, max_priority_fee_per_gas: u128)
fn set_max_priority_fee_per_gas(&mut self, max_priority_fee_per_gas: u128)
Source§fn set_gas_limit(&mut self, gas_limit: u64)
fn set_gas_limit(&mut self, gas_limit: u64)
Source§fn access_list(&self) -> Option<&AccessList>
fn access_list(&self) -> Option<&AccessList>
Source§fn set_access_list(&mut self, access_list: AccessList)
fn set_access_list(&mut self, access_list: AccessList)
Source§fn complete_type(&self, ty: TxType) -> Result<(), Vec<&'static str>>
fn complete_type(&self, ty: TxType) -> Result<(), Vec<&'static str>>
Source§fn can_submit(&self) -> bool
fn can_submit(&self) -> bool
eth_sendTransaction
endpoint.Source§fn can_build(&self) -> bool
fn can_build(&self) -> bool
Source§fn output_tx_type(&self) -> TxType
fn output_tx_type(&self) -> TxType
Source§fn output_tx_type_checked(&self) -> Option<TxType>
fn output_tx_type_checked(&self) -> Option<TxType>
None
if
the builder is not ready to build.Source§fn prep_for_submission(&mut self)
fn prep_for_submission(&mut self)
Source§fn build_unsigned(self) -> BuildResult<TypedTransaction, PodNetwork>
fn build_unsigned(self) -> BuildResult<TypedTransaction, PodNetwork>
Source§async fn build<W: NetworkWallet<PodNetwork>>(
self,
wallet: &W,
) -> Result<<PodNetwork as Network>::TxEnvelope, TransactionBuilderError<PodNetwork>>
async fn build<W: NetworkWallet<PodNetwork>>( self, wallet: &W, ) -> Result<<PodNetwork as Network>::TxEnvelope, TransactionBuilderError<PodNetwork>>
Source§fn with_chain_id(self, chain_id: u64) -> Self
fn with_chain_id(self, chain_id: u64) -> Self
Source§fn with_nonce(self, nonce: u64) -> Self
fn with_nonce(self, nonce: u64) -> Self
Source§fn without_nonce(self) -> Self
fn without_nonce(self) -> Self
Source§fn with_input<T>(self, input: T) -> Self
fn with_input<T>(self, input: T) -> Self
Source§fn set_input_kind<T>(&mut self, input: T, _: TransactionInputKind)
fn set_input_kind<T>(&mut self, input: T, _: TransactionInputKind)
Source§fn with_input_kind<T>(self, input: T, kind: TransactionInputKind) -> Self
fn with_input_kind<T>(self, input: T, kind: TransactionInputKind) -> Self
Source§fn with_kind(self, kind: TxKind) -> Self
fn with_kind(self, kind: TxKind) -> Self
Source§fn set_create(&mut self)
fn set_create(&mut self)
to
field to a create call.Source§fn into_create(self) -> Self
fn into_create(self) -> Self
to
field to a create call.Source§fn set_deploy_code<T>(&mut self, code: T)
fn set_deploy_code<T>(&mut self, code: T)
to
field to TxKind::Create
.Source§fn with_deploy_code<T>(self, code: T) -> Self
fn with_deploy_code<T>(self, code: T) -> Self
to
field to TxKind::Create
.Source§fn set_call<T>(&mut self, t: &T)where
T: SolCall,
fn set_call<T>(&mut self, t: &T)where
T: SolCall,
to
field
if it is set to TxKind::Create
.Source§fn calculate_create_address(&self) -> Option<Address>
fn calculate_create_address(&self) -> Option<Address>
Source§fn with_value(self, value: Uint<256, 4>) -> Self
fn with_value(self, value: Uint<256, 4>) -> Self
Source§fn with_gas_price(self, gas_price: u128) -> Self
fn with_gas_price(self, gas_price: u128) -> Self
Source§fn with_max_fee_per_gas(self, max_fee_per_gas: u128) -> Self
fn with_max_fee_per_gas(self, max_fee_per_gas: u128) -> Self
Source§fn with_max_priority_fee_per_gas(self, max_priority_fee_per_gas: u128) -> Self
fn with_max_priority_fee_per_gas(self, max_priority_fee_per_gas: u128) -> Self
Source§fn with_gas_limit(self, gas_limit: u64) -> Self
fn with_gas_limit(self, gas_limit: u64) -> Self
Source§fn with_access_list(self, access_list: AccessList) -> Self
fn with_access_list(self, access_list: AccessList) -> Self
Source§fn complete_preferred(&self) -> Result<(), Vec<&'static str>>
fn complete_preferred(&self) -> Result<(), Vec<&'static str>>
Source§fn assert_preferred(&self, ty: <N as Network>::TxType)
fn assert_preferred(&self, ty: <N as Network>::TxType)
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
fn assert_preferred_chained(self, ty: <N as Network>::TxType) -> Self
dbg_assert_eq!
to check the builder status, and will have no affect
in release builds.Auto Trait Implementations§
impl !Freeze for PodTransactionRequest
impl RefUnwindSafe for PodTransactionRequest
impl Send for PodTransactionRequest
impl Sync for PodTransactionRequest
impl Unpin for PodTransactionRequest
impl UnwindSafe for PodTransactionRequest
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§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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