# `Cartouche.Transaction.V3`
[🔗](https://github.com/zenhive/cartouche/blob/main/lib/cartouche/transaction/v3.ex#L1)

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

# `access_list`

```elixir
@type access_list() :: [{&lt;&lt;_::160&gt;&gt;, [&lt;&lt;_::256&gt;&gt;]}]
```

# `t`

```elixir
@type t() :: %Cartouche.Transaction.V3{
  access_list: access_list(),
  amount: integer(),
  blob_versioned_hashes: [&lt;&lt;_::256&gt;&gt;],
  chain_id: integer(),
  data: binary(),
  destination: &lt;&lt;_::160&gt;&gt;,
  gas_limit: integer(),
  max_fee_per_blob_gas: integer(),
  max_fee_per_gas: integer(),
  max_priority_fee_per_gas: integer(),
  nonce: integer(),
  signature_r: &lt;&lt;_::256&gt;&gt; | nil,
  signature_s: &lt;&lt;_::256&gt;&gt; | nil,
  signature_y_parity: boolean() | nil
}
```

# `add_signature`

```elixir
@spec add_signature(t(), &lt;&lt;_::512, _::_*8&gt;&gt;) :: t()
```

Adds a signature to a transaction from a packed binary (`r <> s <> v`).

# `add_signature`

```elixir
@spec add_signature(t(), boolean(), &lt;&lt;_::256&gt;&gt;, &lt;&lt;_::256&gt;&gt;) :: t()
```

Adds explicit signature fields to a transaction.

# `decode`

```elixir
@spec decode(binary()) :: {:ok, t()} | {:error, String.t()}
```

Decode a signed EIP-4844 blob transaction envelope.

# `encode`

```elixir
@spec encode(t()) :: binary()
```

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.

# `get_signature`

```elixir
@spec get_signature(t()) :: {:ok, binary()} | {:error, String.t()}
```

Recovers a signature from a transaction, if it has been signed.

# `hash`

```elixir
@spec hash(t()) :: &lt;&lt;_::256&gt;&gt;
```

Hashes the typed transaction bytes.

# `new`

```elixir
@spec new(
  integer(),
  integer() | {integer(), :wei | :gwei} | nil,
  integer() | {integer(), :wei | :gwei} | nil,
  integer(),
  &lt;&lt;_::160&gt;&gt;,
  integer() | {integer(), :wei | :gwei},
  binary(),
  access_list(),
  integer() | {integer(), :wei | :gwei} | nil,
  [&lt;&lt;_::256&gt;&gt;],
  atom() | integer() | nil
) :: t()
```

Constructs a new V3 (EIP-4844) Ethereum transaction.

# `recover_signer`

```elixir
@spec recover_signer(t()) :: {:ok, &lt;&lt;_::160&gt;&gt;} | {:error, String.t()}
```

Recovers the signer from a signed V3 transaction.

# `sign`

```elixir
@spec sign(t(), GenServer.name()) :: {:ok, t()} | {:error, String.t()}
```

Signs a V3 transaction with the given signer process.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
