#[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#[envelope(typed = MyTypedTransaction)]- Generate a corresponding TypedTransaction enum (optional)
§Variant Attributes
- Each variant must be annotated with
envelopeattribute with one of the following options:#[envelope(ty = N)]- Specify the transaction type ID (0-255)#[envelope(ty = N, typed = CustomType)]- Use a custom transaction type for this variant in the generated TypedTransaction (optional)#[envelope(flatten)]- Flatten this variant to delegate to inner envelope type
§Generated Code
The macro generates:
- A
MyTxTypeenum with transaction type variants - Implementations of
Transaction,Typed2718,Encodable2718,Decodable2718 - Serde serialization/deserialization support (if
serdefeature is enabled) - Arbitrary implementations (if
arbitraryfeature is enabled) - Optionally, a TypedTransaction enum (if
typedattribute is specified)