Represents a V3 or EIP-4844 blob transaction.
This module encodes the execution-layer transaction envelope only. Blob sidecars (blobs, KZG commitments, and KZG proofs) are propagated separately and are not part of the canonical signed transaction bytes.
Examples
iex> tx =
...> Cartouche.Transaction.V3.new(
...> 1,
...> {1, :gwei},
...> {100, :gwei},
...> 100_000,
...> <<1::160>>,
...> {2, :wei},
...> <<1, 2, 3>>,
...> [],
...> {1, :wei},
...> [<<1, 0::248>>],
...> :goerli
...> )
...> tx = Cartouche.Transaction.V3.add_signature(tx, true, <<0x01::256>>, <<0x02::256>>)
iex> {:ok, decoded} = tx |> Cartouche.Transaction.V3.encode() |> Cartouche.Transaction.V3.decode()
iex> decoded == tx
true
Summary
Functions
Adds a signature to a transaction from a packed binary (r <> s <> v).
Adds explicit signature fields to a transaction.
Decode a signed EIP-4844 blob transaction envelope.
Build an EIP-2718 typed RLP-encoded blob transaction.
Recovers a signature from a transaction, if it has been signed.
Hashes the typed transaction bytes.
Constructs a new V3 (EIP-4844) Ethereum transaction.
Recovers the signer from a signed V3 transaction.
Signs a V3 transaction with the given signer process.
Types
@type access_list() :: [{<<_::160>>, [<<_::256>>]}]
@type t() :: %Cartouche.Transaction.V3{ access_list: access_list(), amount: integer(), blob_versioned_hashes: [<<_::256>>], chain_id: integer(), data: binary(), destination: <<_::160>>, gas_limit: integer(), max_fee_per_blob_gas: integer(), max_fee_per_gas: integer(), max_priority_fee_per_gas: integer(), nonce: integer(), signature_r: <<_::256>> | nil, signature_s: <<_::256>> | nil, signature_y_parity: boolean() | nil }
Functions
Adds a signature to a transaction from a packed binary (r <> s <> v).
Adds explicit signature fields to a transaction.
Decode a signed EIP-4844 blob transaction envelope.
Build an EIP-2718 typed RLP-encoded blob transaction.
If any signature field is nil, the encoded payload omits
signature_y_parity, signature_r, and signature_s and can be used as the
signing preimage.
Recovers a signature from a transaction, if it has been signed.
@spec hash(t()) :: <<_::256>>
Hashes the typed transaction bytes.
@spec new( integer(), integer() | {integer(), :wei | :gwei} | nil, integer() | {integer(), :wei | :gwei} | nil, integer(), <<_::160>>, integer() | {integer(), :wei | :gwei}, binary(), access_list(), integer() | {integer(), :wei | :gwei} | nil, [<<_::256>>], atom() | integer() | nil ) :: t()
Constructs a new V3 (EIP-4844) Ethereum transaction.
Recovers the signer from a signed V3 transaction.
@spec sign(t(), GenServer.name()) :: {:ok, t()} | {:error, String.t()}
Signs a V3 transaction with the given signer process.