types

package
v1.19.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package types holds the OP-Stack-specific transaction and receipt types. Consumers import it as optypes.

Index

Constants

View Source
const DepositTxType = byte(0x7E)

DepositTxType is the EIP-2718 type byte of OP Stack deposit transactions.

View Source
const PostExecTxType = byte(0x7D)

PostExecTxType is the EIP-2718 type byte of OP Stack post-execution transactions.

Variables

This section is empty.

Functions

func IsDepositTx

func IsDepositTx(tx *types.Transaction) bool

IsDepositTx reports whether tx is an OP Stack deposit transaction.

func IsPostExecTx

func IsPostExecTx(tx *types.Transaction) bool

IsPostExecTx reports whether tx is an OP Stack post-execution transaction.

Like the deposit helpers in deposit_tx.go, this is transition-only: a go-ethereum *types.Transaction can hold a post-exec tx only while the build resolves to op-geth. After the cutover to upstream go-ethereum the 0x7D type is rejected on decode, so this is removed; the durable shape decodes raw bytes via UnmarshalPostExecTx.

func IsSystemTx

func IsSystemTx(tx *types.Transaction) (bool, error)

IsSystemTx reports whether tx is a deposit that is a system transaction, exempt from the L2 gas limit. It errors if tx is not a deposit transaction.

func Mint

func Mint(tx *types.Transaction) (*big.Int, error)

Mint returns the ETH minted by a deposit transaction. A deposit that mints nothing yields zero, never nil: the wire encoding does not distinguish a nil from a zero mint, and the transaction is decoded from its wire bytes. It errors if tx is not a deposit transaction.

func SourceHash

func SourceHash(tx *types.Transaction) (common.Hash, error)

SourceHash returns the source hash of a deposit transaction. It errors if tx is not a deposit transaction.

Types

type DepositTx

type DepositTx struct {
	// SourceHash uniquely identifies the source of the deposit.
	SourceHash common.Hash
	// From is the sender address, determined by the deposit's origin instead of a signature.
	From common.Address
	// To is the recipient; nil means contract creation.
	To *common.Address `rlp:"nil"`
	// Mint is minted on L2, locked on L1; nil if no minting. Note that nil and
	// zero share the same wire encoding and decode to zero.
	Mint *big.Int `rlp:"nil"`
	// Value is transferred from the L2 balance, executed after Mint (if any).
	Value *big.Int
	// Gas is the gas limit.
	Gas uint64
	// IsSystemTransaction indicates the transaction is exempt from the L2 gas limit.
	IsSystemTransaction bool
	// Data is the calldata.
	Data []byte
}

DepositTx is an OP Stack deposit transaction, derived from L1 (or generated for network upgrades) rather than signed by a user. Its canonical encoding is DepositTxType || RLP(fields), matching op-geth's types.DepositTx wire format.

func UnmarshalDepositTx

func UnmarshalDepositTx(raw []byte) (*DepositTx, error)

UnmarshalDepositTx decodes a deposit transaction from its EIP-2718 encoding.

func (*DepositTx) MarshalBinary

func (d *DepositTx) MarshalBinary() ([]byte, error)

MarshalBinary returns the canonical EIP-2718 encoding of the deposit transaction.

type PostExecTx

type PostExecTx struct {
	Data []byte
}

PostExecTx is a synthetic, unsigned OP Stack transaction used to carry post-execution metadata in SDM blocks. Its canonical encoding is PostExecTxType || Data, where Data is appended verbatim with no outer RLP envelope, matching op-geth's types.PostExecTx wire format. Data is itself an RLP-encoded payload, but op-geth (and this type) treat it as opaque bytes and never parse it.

func UnmarshalPostExecTx

func UnmarshalPostExecTx(raw []byte) (*PostExecTx, error)

UnmarshalPostExecTx decodes a post-exec transaction from its EIP-2718 encoding. Like op-geth, it rejects an empty payload.

func (*PostExecTx) MarshalBinary

func (p *PostExecTx) MarshalBinary() ([]byte, error)

MarshalBinary returns the canonical EIP-2718 encoding of the post-exec transaction.

type Receipt

type Receipt struct {
	types.Receipt
	// DepositNonce was introduced in Regolith to store the actual nonce used by
	// deposit transactions.
	DepositNonce *uint64 `json:"depositNonce,omitempty"`
	// DepositReceiptVersion was introduced in Canyon to indicate an update to
	// how receipt hashes should be computed when set; nil when not set.
	DepositReceiptVersion *uint64 `json:"depositReceiptVersion,omitempty"`
	// L1GasPrice is present from pre-bedrock; the L1 base fee after Bedrock.
	L1GasPrice *big.Int `json:"l1GasPrice,omitempty"`
	// L1BlobBaseFee is nil prior to the Ecotone hardfork.
	L1BlobBaseFee *big.Int `json:"l1BlobBaseFee,omitempty"`
	// L1GasUsed is present from pre-bedrock, deprecated as of Fjord.
	L1GasUsed *big.Int `json:"l1GasUsed,omitempty"`
	// L1Fee is present from pre-bedrock.
	L1Fee *big.Int `json:"l1Fee,omitempty"`
	// FeeScalar is present from pre-bedrock to Ecotone; nil after Ecotone.
	FeeScalar *big.Float `json:"l1FeeScalar,omitempty"`
	// L1BaseFeeScalar is nil prior to the Ecotone hardfork.
	L1BaseFeeScalar *uint64 `json:"l1BaseFeeScalar,omitempty"`
	// L1BlobBaseFeeScalar is nil prior to the Ecotone hardfork.
	L1BlobBaseFeeScalar *uint64 `json:"l1BlobBaseFeeScalar,omitempty"`
	// OperatorFeeScalar is nil prior to the Isthmus hardfork.
	OperatorFeeScalar *uint64 `json:"operatorFeeScalar,omitempty"`
	// OperatorFeeConstant is nil prior to the Isthmus hardfork.
	OperatorFeeConstant *uint64 `json:"operatorFeeConstant,omitempty"`
	// DAFootprintGasScalar is nil prior to the Jovian hardfork.
	DAFootprintGasScalar *uint64 `json:"daFootprintGasScalar,omitempty"`
}

Receipt extends go-ethereum's receipt with the OP Stack fields that L2 endpoints include in eth_getTransactionReceipt responses. The full op-geth field set is carried — not just the fields the monorepo services read — so receipt JSON round-trips completely. JSON field names match op-geth's types.Receipt verbatim for wire compatibility; values are hex-encoded on the wire, hence the custom JSON methods.

While the go.mod replace still points at op-geth, the embedded types.Receipt carries identically-named fields. UnmarshalJSON populates both copies consistently; when marshaling, the outer fields take precedence.

func (Receipt) MarshalJSON

func (r Receipt) MarshalJSON() ([]byte, error)

MarshalJSON encodes the embedded go-ethereum receipt and merges the OP Stack extension fields into the same JSON object, so the encoding round-trips.

func (*Receipt) UnmarshalJSON

func (r *Receipt) UnmarshalJSON(input []byte) error

UnmarshalJSON decodes both the embedded go-ethereum receipt and the OP Stack extension fields from the same JSON object.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL