FromRecoveredTx

Trait FromRecoveredTx 

pub trait FromRecoveredTx<Tx> {
    // Required method
    fn from_recovered_tx(tx: &Tx, sender: Address) -> Self;
}
Available on crate feature evm only.
Expand description

Helper trait for building a transaction environment from a recovered transaction.

This trait enables the conversion of consensus transaction types (which have been recovered with their sender address) into the EVM’s transaction environment. It’s automatically used when a Recovered<T> type is passed to the EVM’s transact method.

The expectation is that any recovered consensus transaction can be converted into the transaction type that the EVM operates on (typically TxEnv).

§Implementation

This trait is implemented for all standard Ethereum transaction types ([TxLegacy], [TxEip2930], [TxEip1559], [TxEip4844], [TxEip7702]) and transaction envelopes ([EthereumTxEnvelope]).

§Example

// Recover the signer from a transaction
let recovered = tx.recover_signer()?;

// The recovered transaction can now be used with the EVM
// This works because Recovered<T> implements IntoTxEnv when T implements FromRecoveredTx
evm.transact(recovered)?;

Required Methods§

fn from_recovered_tx(tx: &Tx, sender: Address) -> Self

Builds a TxEnv from a transaction and a sender address.

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.

Implementors§

§

impl FromRecoveredTx<OpTxEnvelope> for OpTransaction<TxEnv>

§

impl FromRecoveredTx<OpTxEnvelope> for TxEnv

§

impl FromRecoveredTx<TxDeposit> for TxEnv

§

impl FromRecoveredTx<TxEip1559> for TxEnv

§

impl FromRecoveredTx<TxEip2930> for TxEnv

§

impl FromRecoveredTx<TxEip4844> for TxEnv

§

impl FromRecoveredTx<TxEip7702> for TxEnv

§

impl FromRecoveredTx<TxLegacy> for TxEnv

§

impl<Eip4844> FromRecoveredTx<EthereumTxEnvelope<Eip4844>> for TxEnv
where Eip4844: AsRef<TxEip4844>,

§

impl<TxEnv, T> FromRecoveredTx<&T> for TxEnv
where TxEnv: FromRecoveredTx<T>,