Skip to main content

NetworkTransactionBuilder

Trait NetworkTransactionBuilder 

Source
pub trait NetworkTransactionBuilder<N: Network>: TransactionBuilder {
    // Required methods
    fn can_submit(&self) -> bool;
    fn can_build(&self) -> bool;
    fn complete_type(&self, ty: N::TxType) -> Result<(), Vec<&'static str>>;
    fn output_tx_type(&self) -> N::TxType;
    fn output_tx_type_checked(&self) -> Option<N::TxType>;
    fn prep_for_submission(&mut self);
    fn build_unsigned(self) -> BuildResult<N::UnsignedTx, N>;
    fn build<W: NetworkWallet<N>>(
        self,
        wallet: &W,
    ) -> impl Send + Future<Output = Result<N::TxEnvelope, TransactionBuilderError<N>>>;

    // Provided methods
    fn complete_preferred(&self) -> Result<(), Vec<&'static str>> { ... }
    fn assert_preferred(&self, ty: N::TxType) { ... }
    fn assert_preferred_chained(self, ty: N::TxType) -> Self { ... }
}
Expand description

Network-specific transaction builder.

Extends TransactionBuilder with build_unsigned and build methods.

Required Methods§

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 complete_type(&self, ty: N::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 output_tx_type(&self) -> N::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<N::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).

This is useful for transaction requests that have multiple conflicting fields. While these may be buildable, they may not be submitted to the RPC. This method should be called before RPC submission, but is not necessary before building.

Source

fn build_unsigned(self) -> BuildResult<N::UnsignedTx, N>

Build an unsigned, but typed, transaction.

Source

fn build<W: NetworkWallet<N>>( self, wallet: &W, ) -> impl Send + Future<Output = Result<N::TxEnvelope, TransactionBuilderError<N>>>

Build a signed transaction.

Provided Methods§

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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl NetworkTransactionBuilder<AnyNetwork> for WithOtherFields<TransactionRequest>

Source§

fn build_unsigned( self, ) -> BuildResult<<AnyNetwork as Network>::UnsignedTx, AnyNetwork>

Build an unsigned typed transaction.

This method validates that all required fields are present and builds an unsigned transaction. Returns an error if any required fields are missing.

§Limitations

The TransactionRequest can only build Ethereum transaction types (Legacy, EIP-2930, EIP-1559, EIP-4844, EIP-7702). Attempting to build unknown transaction types will result in an error.

§Errors

Returns TransactionBuilderError::InvalidTransactionRequest if required fields are missing for the transaction type.

Source§

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

Build and sign a transaction using the provided wallet.

This method signs the transaction request with the given wallet and returns a signed transaction envelope ready for submission to the network.

§Limitations

The TransactionRequest can only build Ethereum transaction types. Unknown transaction types cannot be signed through this builder.

§Errors

Returns an error if signing fails or if the wallet cannot produce the required signature type for the transaction.

Source§

fn can_submit(&self) -> bool

Source§

fn can_build(&self) -> bool

Source§

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

Source§

fn output_tx_type(&self) -> <AnyNetwork as Network>::TxType

Source§

fn output_tx_type_checked(&self) -> Option<<AnyNetwork as Network>::TxType>

Source§

fn prep_for_submission(&mut self)

Source§

impl NetworkTransactionBuilder<Ethereum> for TransactionRequest

Implementors§