# `Cartouche.DebugTrace.StructLog`
[🔗](https://github.com/zenhive/cartouche/blob/main/lib/cartouche/debug_trace.ex#L16)

One execution step inside a `Cartouche.DebugTrace` — the EVM opcode,
program counter, call depth, remaining gas, gas cost of this step, and
the stack snapshot at that point.

# `t`

```elixir
@type t() :: %Cartouche.DebugTrace.StructLog{
  depth: integer(),
  gas: integer(),
  gas_cost: integer(),
  op: atom(),
  pc: integer(),
  stack: [binary()]
}
```

# `deserialize`

```elixir
@spec deserialize(map()) :: t() | no_return()
```

Deserializes a trace's struct-log into a struct.

Raises `ArgumentError` for unknown opcode strings or non-binary `op` —
the whitelist covers Cancun-era opcodes plus the legacy Geth `SHA3` alias;
future-fork additions surface as raises rather than silent atom-table growth.

## Examples

    iex> %{
    ...>   "depth" => 1,
    ...>   "gas" => 599978565,
    ...>   "gasCost" => 3,
    ...>   "op" => "PUSH1",
    ...>   "pc" => 2,
    ...>   "stack" => ["0x80"]
    ...> }
    ...> |> Cartouche.DebugTrace.StructLog.deserialize()
    %Cartouche.DebugTrace.StructLog{
      depth: 1,
      gas: 599978565,
      gas_cost: 3,
      op: :PUSH1,
      pc: 2,
      stack: [~h[0x80]]
    }

# `serialize`

```elixir
@spec serialize(t()) :: map()
```

Serializes a trace's struct-log into a json map.

## Examples

    iex> %Cartouche.DebugTrace.StructLog{
    ...>   depth: 1,
    ...>   gas: 599978565,
    ...>   gas_cost: 3,
    ...>   op: :PUSH1,
    ...>   pc: 2,
    ...>   stack: [~h[0x80]]
    ...> }
    ...> |> Cartouche.DebugTrace.StructLog.serialize()
    %{
      depth: 1,
      gas: 599978565,
      gasCost: 3,
      op: "PUSH1",
      pc: 2,
      stack: ["0x80"]
    }

---

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