pub struct TransactionRequest {Show 16 fields
pub from: Option<Address>,
pub to: Option<TxKind>,
pub gas_price: Option<u128>,
pub max_fee_per_gas: Option<u128>,
pub max_priority_fee_per_gas: Option<u128>,
pub max_fee_per_blob_gas: Option<u128>,
pub gas: Option<u64>,
pub value: Option<Uint<256, 4>>,
pub input: TransactionInput,
pub nonce: Option<u64>,
pub chain_id: Option<u64>,
pub access_list: Option<AccessList>,
pub transaction_type: Option<u8>,
pub blob_versioned_hashes: Option<Vec<FixedBytes<32>>>,
pub sidecar: Option<BlobTransactionSidecar>,
pub authorization_list: Option<Vec<SignedAuthorization>>,
}
eth
only.Expand description
Represents all transaction requests to/from RPC.
Fields§
§from: Option<Address>
The address of the transaction author.
to: Option<TxKind>
The destination address of the transaction.
gas_price: Option<u128>
The legacy gas price.
max_fee_per_gas: Option<u128>
The max base fee per gas the sender is willing to pay.
max_priority_fee_per_gas: Option<u128>
The max priority fee per gas the sender is willing to pay, also called the miner tip.
max_fee_per_blob_gas: Option<u128>
The max fee per blob gas for EIP-4844 blob transactions.
gas: Option<u64>
The gas limit for the transaction.
value: Option<Uint<256, 4>>
The value transferred in the transaction, in wei.
input: TransactionInput
Transaction data.
nonce: Option<u64>
The nonce of the transaction.
chain_id: Option<u64>
The chain ID for the transaction.
access_list: Option<AccessList>
An EIP-2930 access list, which lowers cost for accessing accounts and storages in the list. See EIP-2930 for more information.
transaction_type: Option<u8>
The EIP-2718 transaction type. See EIP-2718 for more information.
blob_versioned_hashes: Option<Vec<FixedBytes<32>>>
Blob versioned hashes for EIP-4844 transactions.
sidecar: Option<BlobTransactionSidecar>
Blob sidecar for EIP-4844 transactions.
Authorization list for for EIP-7702 transactions.
Implementations§
source§impl TransactionRequest
impl TransactionRequest
sourcepub const fn from(self, from: Address) -> TransactionRequest
pub const fn from(self, from: Address) -> TransactionRequest
Sets the from
field in the call to the provided address
sourcepub const fn transaction_type(self, transaction_type: u8) -> TransactionRequest
pub const fn transaction_type(self, transaction_type: u8) -> TransactionRequest
Sets the transactions type for the transactions.
sourcepub const fn gas_limit(self, gas_limit: u64) -> TransactionRequest
pub const fn gas_limit(self, gas_limit: u64) -> TransactionRequest
Sets the gas limit for the transaction.
sourcepub const fn nonce(self, nonce: u64) -> TransactionRequest
pub const fn nonce(self, nonce: u64) -> TransactionRequest
Sets the nonce for the transaction.
sourcepub const fn max_fee_per_gas(self, max_fee_per_gas: u128) -> TransactionRequest
pub const fn max_fee_per_gas(self, max_fee_per_gas: u128) -> TransactionRequest
Sets the maximum fee per gas for the transaction.
sourcepub const fn max_priority_fee_per_gas(
self,
max_priority_fee_per_gas: u128,
) -> TransactionRequest
pub const fn max_priority_fee_per_gas( self, max_priority_fee_per_gas: u128, ) -> TransactionRequest
Sets the maximum priority fee per gas for the transaction.
sourcepub const fn to(self, to: Address) -> TransactionRequest
pub const fn to(self, to: Address) -> TransactionRequest
Sets the recipient address for the transaction.
sourcepub const fn value(self, value: Uint<256, 4>) -> TransactionRequest
pub const fn value(self, value: Uint<256, 4>) -> TransactionRequest
Sets the value (amount) for the transaction.
sourcepub fn access_list(self, access_list: AccessList) -> TransactionRequest
pub fn access_list(self, access_list: AccessList) -> TransactionRequest
Sets the access list for the transaction.
sourcepub fn input(self, input: TransactionInput) -> TransactionRequest
pub fn input(self, input: TransactionInput) -> TransactionRequest
Sets the input data for the transaction.
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 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 const fn preferred_type(&self) -> TxType
pub const fn preferred_type(&self) -> TxType
Check this builder’s preferred type, based on the fields that 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
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.
sourcepub fn build_typed_tx(self) -> Result<TypedTransaction, TransactionRequest>
pub fn build_typed_tx(self) -> Result<TypedTransaction, TransactionRequest>
Build an TypedTransaction
In case Ok(...)
is returned, the TypedTransaction
is guaranteed to be complete, e.g.
sendable to the network.
sourcepub fn build_consensus_tx(self) -> Result<TypedTransaction, BuildTransactionErr>
pub fn build_consensus_tx(self) -> Result<TypedTransaction, BuildTransactionErr>
Build an TypedTransaction
.
In case Ok(...)
is returned, the TypedTransaction
does not guarantee to be complete,
e.g. sendable to the network.
E.g. a particular case is when the transaction is of type Eip4844
and the sidecar
is not
set, in this case the transaction is not complete. It can still be used to calculate the
signature of the transaction though.
In case the requirement is to build a complete transaction, use build_typed_tx
instead.
Trait Implementations§
source§impl<'arbitrary> Arbitrary<'arbitrary> for TransactionRequest
impl<'arbitrary> Arbitrary<'arbitrary> for TransactionRequest
source§fn arbitrary(
u: &mut Unstructured<'arbitrary>,
) -> Result<TransactionRequest, Error>
fn arbitrary( u: &mut Unstructured<'arbitrary>, ) -> Result<TransactionRequest, Error>
Self
from the given unstructured data. Read moresource§fn arbitrary_take_rest(
u: Unstructured<'arbitrary>,
) -> Result<TransactionRequest, Error>
fn arbitrary_take_rest( u: Unstructured<'arbitrary>, ) -> Result<TransactionRequest, Error>
Self
from the entirety of the given
unstructured data. Read moresource§impl Clone for TransactionRequest
impl Clone for TransactionRequest
source§fn clone(&self) -> TransactionRequest
fn clone(&self) -> TransactionRequest
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for TransactionRequest
impl Debug for TransactionRequest
source§impl Default for TransactionRequest
impl Default for TransactionRequest
source§fn default() -> TransactionRequest
fn default() -> TransactionRequest
source§impl<'de> Deserialize<'de> for TransactionRequest
impl<'de> Deserialize<'de> for TransactionRequest
source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<TransactionRequest, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<TransactionRequest, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl From<Transaction> for TransactionRequest
impl From<Transaction> for TransactionRequest
source§fn from(tx: Transaction) -> TransactionRequest
fn from(tx: Transaction) -> TransactionRequest
source§impl From<TxEip1559> for TransactionRequest
impl From<TxEip1559> for TransactionRequest
source§fn from(tx: TxEip1559) -> TransactionRequest
fn from(tx: TxEip1559) -> TransactionRequest
source§impl From<TxEip2930> for TransactionRequest
impl From<TxEip2930> for TransactionRequest
source§fn from(tx: TxEip2930) -> TransactionRequest
fn from(tx: TxEip2930) -> TransactionRequest
source§impl From<TxEip4844> for TransactionRequest
impl From<TxEip4844> for TransactionRequest
source§fn from(tx: TxEip4844) -> TransactionRequest
fn from(tx: TxEip4844) -> TransactionRequest
source§impl From<TxEip4844Variant> for TransactionRequest
impl From<TxEip4844Variant> for TransactionRequest
source§fn from(tx: TxEip4844Variant) -> TransactionRequest
fn from(tx: TxEip4844Variant) -> TransactionRequest
source§impl From<TxEip4844WithSidecar> for TransactionRequest
impl From<TxEip4844WithSidecar> for TransactionRequest
source§fn from(tx: TxEip4844WithSidecar) -> TransactionRequest
fn from(tx: TxEip4844WithSidecar) -> TransactionRequest
source§impl From<TxEip7702> for TransactionRequest
impl From<TxEip7702> for TransactionRequest
source§fn from(tx: TxEip7702) -> TransactionRequest
fn from(tx: TxEip7702) -> TransactionRequest
source§impl From<TxEnvelope> for TransactionRequest
impl From<TxEnvelope> for TransactionRequest
source§fn from(envelope: TxEnvelope) -> TransactionRequest
fn from(envelope: TxEnvelope) -> TransactionRequest
source§impl From<TxLegacy> for TransactionRequest
impl From<TxLegacy> for TransactionRequest
source§fn from(tx: TxLegacy) -> TransactionRequest
fn from(tx: TxLegacy) -> TransactionRequest
source§impl From<TypedTransaction> for TransactionRequest
impl From<TypedTransaction> for TransactionRequest
source§fn from(tx: TypedTransaction) -> TransactionRequest
fn from(tx: TypedTransaction) -> TransactionRequest
source§impl Hash for TransactionRequest
impl Hash for TransactionRequest
source§impl PartialEq for TransactionRequest
impl PartialEq for TransactionRequest
source§impl Serialize for TransactionRequest
impl Serialize for TransactionRequest
source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for TransactionRequest
impl StructuralPartialEq for TransactionRequest
Auto Trait Implementations§
impl !Freeze for TransactionRequest
impl RefUnwindSafe for TransactionRequest
impl Send for TransactionRequest
impl Sync for TransactionRequest
impl Unpin for TransactionRequest
impl UnwindSafe for TransactionRequest
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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