txbuilder

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildBlobTx

func BuildBlobTx(txData *TxMetadata, blobRefs [][]string) (*types.BlobTx, error)

BuildBlobTx constructs a blob transaction (EIP-4844) with the specified transaction metadata and blob references. It processes multiple blob references, each containing data that will be committed to the blob sidecar. The transaction must have a valid 'To' address as blob transactions cannot be contract deployments. Returns a complete BlobTx with all blobs, commitments, proofs, and versioned hashes.

func DynFeeTx

func DynFeeTx(txData *TxMetadata) (*types.DynamicFeeTx, error)

DynFeeTx creates a dynamic fee transaction (EIP-1559) from the provided transaction metadata. It constructs a DynamicFeeTx with gas tip cap, gas fee cap, gas limit, recipient address, value, data, and access list. This transaction type supports the EIP-1559 fee market with separate base fee and priority fee components.

func GenerateCellProofs added in v1.1.3

func GenerateCellProofs(sidecar *types.BlobTxSidecar) ([]kzg4844.Proof, error)

GenerateCellProofs generates cell proofs for blob v1 transactions (experimental feature). This function requires blob-v1 support to be initialized, otherwise returns an error. Used for advanced blob transaction types that require cell-level proofs.

func MarshalBlobV1Tx added in v1.1.2

func MarshalBlobV1Tx(tx *types.Transaction, cellProofs []kzg4844.Proof) ([]byte, error)

MarshalBlobV1Tx marshals a blob v1 transaction with cell proofs into bytes. This function requires blob-v1 support to be initialized, otherwise returns an error. Used for encoding experimental blob v1 transaction format with cell proofs.

func ParseBlobRefsBytes

func ParseBlobRefsBytes(blobRefs []string, tx *types.BlobTx) ([]byte, error)

ParseBlobRefsBytes parses an array of blob references and returns the concatenated blob data as bytes. Blob references support multiple formats:

  • "0x..." - hex-encoded data
  • "file:path" - data from file
  • "url:http://..." - data from HTTP URL
  • "repeat:0xdata:count" - repeat hex data count times
  • "random" or "random:size" - generate random data of specified or random size
  • "copy:index" - copy data from existing blob at index (only for blob transactions)

The tx parameter is used for the "copy" reference type and can be nil for other types.

func SetCodeTx added in v1.1.0

func SetCodeTx(txData *TxMetadata) (*types.SetCodeTx, error)

SetCodeTx creates a set code transaction (EIP-7702) from the provided transaction metadata. It constructs a SetCodeTx that can authorize code changes for externally owned accounts. The transaction must have a valid 'To' address as it cannot be used for contract deployment. Includes authorization list for account code delegation as specified in EIP-7702.

Types

type BlobCommitment

type BlobCommitment struct {
	Blob          *kzg4844.Blob
	Commitment    kzg4844.Commitment
	Proof         kzg4844.Proof
	VersionedHash common.Hash
}

BlobCommitment contains all the cryptographic components needed for an EIP-4844 blob. It includes the blob data itself, the KZG commitment, proof, and the versioned hash that will be included in the transaction. This structure represents a complete blob ready for inclusion in a blob transaction.

func EncodeBlob

func EncodeBlob(data []byte) (*BlobCommitment, error)

EncodeBlob encodes arbitrary byte data into a complete blob commitment structure. It validates the data size against EIP-4844 limits, encodes the data into blob format, generates the KZG commitment and proof, and creates the versioned hash. Returns an error if the data exceeds the maximum blob size or if cryptographic operations fail.

type TxMetadata

type TxMetadata struct {
	GasTipCap  *uint256.Int // a.k.a. maxPriorityFeePerGas
	GasFeeCap  *uint256.Int // a.k.a. maxFeePerGas
	BlobFeeCap *uint256.Int // a.k.a. maxFeePerBlobGas
	Gas        uint64
	To         *common.Address
	Value      *uint256.Int
	Data       []byte
	AccessList types.AccessList
	AuthList   []types.SetCodeAuthorization
}

TxMetadata contains the common transaction parameters used across different transaction types. It provides a unified interface for specifying transaction details including gas parameters, recipient address, value transfer, transaction data, and various EIP extensions like access lists (EIP-2930), blob fees (EIP-4844), and authorization lists (EIP-7702).

Jump to

Keyboard shortcuts

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