Search documentation of Cartouche

# Cartouche.DebugTrace.StructLog (Cartouche v0.1.3)

Copy Markdown View Source

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.

## Summary

### Types

t()

### Functions

deserialize(params)

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

serialize(struct_log)

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

## Types

# t()

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

## Functions

# deserialize(params)

    @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(struct_log)

    @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"]
    }