Transactions

The op-alloy-consensus crate contains types for Optimism EL consensus and communication. Most notably, Optimism extends the Ethereum EIP-2718 transaction envelope to include a deposit variant.

This doc breaks down transaction and other types defined in the op-alloy-consensus crate.

OpTxEnvelope

The OpTxEnvelope type is based on [Alloy][alloy]'s TxEnvelope type.

Optimism modifies the TxEnvelope to the following.

  • Legacy
  • EIP-2930
  • EIP-1559
  • EIP-7702
  • Deposit

Deposit is a custom transaction type that is either an L1 attributes deposit transaction or a user-submitted deposit transaction. Read more about deposit transactions in the specs.

Transaction Types (OpTxType)

The OpTxType enumerates the transaction types using their byte identifier, represents as a u8 in rust.

OpBlock

op-alloy-consensus exports an Optimism block type.

Receipt Types

Just like op-alloy-consensus defines transaction types, it also defines associated receipt types.

OpReceiptEnvelope defines an Eip-2718 receipt envelope type modified for the OP Stack. It contains the following variants - mapping directly to the OpTxEnvelope variants defined above.

  • Legacy
  • EIP-2930
  • EIP-1559
  • EIP-7702
  • Deposit

There is also an OpDepositReceipt type, extending the alloy receipt type with a deposit nonce and deposit receipt version.

Hardforks

Aside from transactions and receipts, op-alloy-consensus exports one other core primitive called Hardforks.

Hardforks provides hardfork transaction constructors - that is, it provides methods that return upgrade transactions for each hardfork. Some of these are the following.