Trait FromRecoveredTx
pub trait FromRecoveredTx<Tx> {
// Required method
fn from_recovered_tx(tx: &Tx, sender: Address) -> Self;
}
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
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.