alloy_rpc_types::transaction

Struct TransactionRequest

Source
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>>,
}
Available on crate feature 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: Option<Vec<SignedAuthorization>>

Authorization list for for EIP-7702 transactions.

Implementations§

Source§

impl TransactionRequest

Source

pub const fn from(self, from: Address) -> TransactionRequest

Sets the from field in the call to the provided address

Source

pub const fn transaction_type(self, transaction_type: u8) -> TransactionRequest

Sets the transactions type for the transactions.

Source

pub const fn gas_limit(self, gas_limit: u64) -> TransactionRequest

Sets the gas limit for the transaction.

Source

pub const fn nonce(self, nonce: u64) -> TransactionRequest

Sets the nonce for the transaction.

Source

pub const fn max_fee_per_gas(self, max_fee_per_gas: u128) -> TransactionRequest

Sets the maximum fee per gas for the transaction.

Source

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.

Source

pub const fn to(self, to: Address) -> TransactionRequest

Sets the recipient address for the transaction.

Source

pub const fn value(self, value: Uint<256, 4>) -> TransactionRequest

Sets the value (amount) for the transaction.

Source

pub fn access_list(self, access_list: AccessList) -> TransactionRequest

Sets the access list for the transaction.

Source

pub fn input(self, input: TransactionInput) -> TransactionRequest

Sets the input data for the transaction.

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

Source

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.

Source

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

Source§

fn arbitrary( u: &mut Unstructured<'arbitrary>, ) -> Result<TransactionRequest, Error>

Generate an arbitrary value of Self from the given unstructured data. Read more
Source§

fn arbitrary_take_rest( u: Unstructured<'arbitrary>, ) -> Result<TransactionRequest, Error>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
Source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

impl Clone for TransactionRequest

Source§

fn clone(&self) -> TransactionRequest

Returns a copy 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 TransactionRequest

Source§

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

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

impl Default for TransactionRequest

Source§

fn default() -> TransactionRequest

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

impl<'de> Deserialize<'de> for TransactionRequest

Source§

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

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

impl From<Transaction> for TransactionRequest

Source§

fn from(tx: Transaction) -> TransactionRequest

Converts to this type from the input type.
Source§

impl From<TxEip1559> for TransactionRequest

Source§

fn from(tx: TxEip1559) -> TransactionRequest

Converts to this type from the input type.
Source§

impl From<TxEip2930> for TransactionRequest

Source§

fn from(tx: TxEip2930) -> TransactionRequest

Converts to this type from the input type.
Source§

impl From<TxEip4844> for TransactionRequest

Source§

fn from(tx: TxEip4844) -> TransactionRequest

Converts to this type from the input type.
Source§

impl From<TxEip4844Variant> for TransactionRequest

Source§

fn from(tx: TxEip4844Variant) -> TransactionRequest

Converts to this type from the input type.
Source§

impl From<TxEip4844WithSidecar> for TransactionRequest

Source§

fn from(tx: TxEip4844WithSidecar) -> TransactionRequest

Converts to this type from the input type.
Source§

impl From<TxEip7702> for TransactionRequest

Source§

fn from(tx: TxEip7702) -> TransactionRequest

Converts to this type from the input type.
Source§

impl From<TxEnvelope> for TransactionRequest

Source§

fn from(envelope: TxEnvelope) -> TransactionRequest

Converts to this type from the input type.
Source§

impl From<TxLegacy> for TransactionRequest

Source§

fn from(tx: TxLegacy) -> TransactionRequest

Converts to this type from the input type.
Source§

impl From<TypedTransaction> for TransactionRequest

Source§

fn from(tx: TypedTransaction) -> TransactionRequest

Converts to this type from the input type.
Source§

impl Hash for TransactionRequest

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for TransactionRequest

Source§

fn eq(&self, other: &TransactionRequest) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for TransactionRequest

Source§

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

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

impl TransactionBuilder4844 for TransactionRequest

Source§

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

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

fn set_max_fee_per_blob_gas(&mut self, max_fee_per_blob_gas: u128)

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

fn blob_sidecar(&self) -> Option<&BlobTransactionSidecar>

Gets the EIP-4844 blob sidecar of the transaction.
Source§

fn set_blob_sidecar(&mut self, sidecar: BlobTransactionSidecar)

Sets the EIP-4844 blob sidecar of the transaction. Read more
Source§

fn with_max_fee_per_blob_gas(self, max_fee_per_blob_gas: u128) -> Self

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

fn with_blob_sidecar(self, sidecar: BlobTransactionSidecar) -> Self

Builder-pattern method for setting the EIP-4844 blob sidecar of the transaction.
Source§

impl TransactionBuilder7702 for TransactionRequest

Source§

fn authorization_list(&self) -> Option<&Vec<SignedAuthorization>>

Get the EIP-7702 authorization list for the transaction.
Source§

fn set_authorization_list( &mut self, authorization_list: Vec<SignedAuthorization>, )

Sets the EIP-7702 authorization list.
Source§

fn with_authorization_list( self, authorization_list: Vec<SignedAuthorization>, ) -> Self

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

impl Eq for TransactionRequest

Source§

impl StructuralPartialEq for TransactionRequest

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, dst: *mut T)

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

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,