Derive Macro TransactionEnvelope

Source
#[derive(TransactionEnvelope)]
{
    // Attributes available to this derive:
    #[envelope]
    #[serde]
}
Expand description

Derive macro for creating transaction envelope types.

This macro generates a transaction envelope implementation that supports multiple transaction types following the EIP-2718 standard.

§Container Attributes

  • #[envelope(tx_type_name = MyTxType)] - Custom name for the generated transaction type enum
  • #[envelope(alloy_consensus = path::to::alloy)] - Custom path to alloy_consensus crate

§Variant Attributes

  • Each variant must be annotated with envelope attribute with one of the following options:
    • #[envelope(ty = N)] - Specify the transaction type ID (0-255)
    • #[envelope(flatten)] - Flatten this variant to delegate to inner envelope type

§Generated Code

The macro generates:

  • A MyTxType enum with transaction type variants
  • Implementations of Transaction, Typed2718, Encodable2718, Decodable2718
  • Serde serialization/deserialization support (if serde feature is enabled)
  • Arbitrary implementations (if arbitrary feature is enabled)