pub struct TransactionRequest {
Show 15 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<u128>, pub value: Option<U256>, pub input: TransactionInput, pub nonce: Option<u64>, pub chain_id: Option<ChainId>, pub access_list: Option<AccessList>, pub transaction_type: Option<u8>, pub blob_versioned_hashes: Option<Vec<B256>>, pub sidecar: Option<BlobTransactionSidecar>,
}
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<u128>

The gas limit for the transaction.

§value: Option<U256>

The value transferred in the transaction, in wei.

§input: TransactionInput

Transaction data.

§nonce: Option<u64>

The nonce of the transaction.

§chain_id: Option<ChainId>

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

Blob versioned hashes for EIP-4844 transactions.

§sidecar: Option<BlobTransactionSidecar>

Blob sidecar for EIP-4844 transactions.

Implementations§

source§

impl TransactionRequest

source

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

Sets the from field in the call to the provided address

source

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

Sets the transactions type for the transactions.

source

pub const fn gas_limit(self, gas_limit: u128) -> Self

Sets the gas limit for the transaction.

source

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

Sets the nonce for the transaction.

source

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

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, ) -> Self

Sets the maximum priority fee per gas for the transaction.

source

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

Sets the recipient address for the transaction.

source

pub const fn value(self, value: U256) -> Self

Sets the value (amount) for the transaction.

source

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

Sets the access list for the transaction.

source

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

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

fn build_legacy(self) -> TxLegacy

Build a legacy transaction.

§Panics

If required fields are missing. Use complete_legacy to check if the request can be built.

source

fn build_1559(self) -> TxEip1559

Build an EIP-1559 transaction.

§Panics

If required fields are missing. Use complete_1559 to check if the request can be built.

source

fn build_2930(self) -> TxEip2930

Build an EIP-2930 transaction.

§Panics

If required fields are missing. Use complete_2930 to check if the request can be built.

source

fn build_4844(self) -> TxEip4844WithSidecar

Build an EIP-4844 transaction.

§Panics

If required fields are missing. Use complete_4844 to check if the request can be built.

source

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

source

fn check_legacy_fields(&self, missing: &mut Vec<&'static str>)

source

fn check_1559_fields(&self, missing: &mut Vec<&'static str>)

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

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_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, Self>

Build an [TypedTransaction]

Trait Implementations§

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

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<Self, __D::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) -> Self

Converts to this type from the input type.
source§

impl From<TxEip1559> for TransactionRequest

source§

fn from(tx: TxEip1559) -> Self

Converts to this type from the input type.
source§

impl From<TxEip2930> for TransactionRequest

source§

fn from(tx: TxEip2930) -> Self

Converts to this type from the input type.
source§

impl From<TxEip4844> for TransactionRequest

source§

fn from(tx: TxEip4844) -> Self

Converts to this type from the input type.
source§

impl From<TxEip4844Variant> for TransactionRequest

source§

fn from(tx: TxEip4844Variant) -> Self

Converts to this type from the input type.
source§

impl From<TxEip4844WithSidecar> for TransactionRequest

source§

fn from(tx: TxEip4844WithSidecar) -> Self

Converts to this type from the input type.
source§

impl From<TxEnvelope> for TransactionRequest

source§

fn from(envelope: TxEnvelope) -> Self

Converts to this type from the input type.
source§

impl From<TxLegacy> for TransactionRequest

source§

fn from(tx: TxLegacy) -> Self

Converts to this type from the input type.
source§

impl From<TypedTransaction> for TransactionRequest

source§

fn from(tx: TypedTransaction) -> Self

Converts to this type from the input type.
source§

impl Hash for TransactionRequest

source§

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

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
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> 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

§

type Output = T

Should always be Self
source§

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

§

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

§

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

§

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

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

§

fn vzip(self) -> V

source§

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

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 464 bytes