Search documentation of Cartouche

# Cartouche.DebugTrace (Cartouche v0.1.3)

Copy Markdown View Source

Represents an Ethereum transaction debug trace, which contains information about the call graph of an executed transaction. Note: this is different from `trace_call` and instead has deep struct logs for execution.

See `Cartouche.RPC.debug_trace_call` for getting traces from an Ethereum JSON-RPC host.

See also:

- QuickNode docs: https://www.quicknode.com/docs/ethereum/debug_traceCall

## Summary

### Types

t()

### Functions

deserialize(params)

Deserializes a trace result from `debug_traceCall`.

serialize(debug_trace)

Serializes a trace result back to a json map.

## Types

# t()

    @type t() :: %Cartouche.DebugTrace{
      failed: boolean(),
      gas: integer(),
      return_value: binary(),
      struct_logs: [Cartouche.DebugTrace.StructLog.t()]
    }

## Functions

# deserialize(params)

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

Deserializes a trace result from `debug_traceCall`.

## Examples

    iex> %{
    ...>   "failed" => false,
    ...>   "gas" => 24034,
    ...>   "returnValue" => "0000000000000000000000000000000000000000000000000858898f93629000",
    ...>   "structLogs" => [
    ...>     %{
    ...>       "depth" => 1,
    ...>       "gas" => 599978568,
    ...>       "gasCost" => 3,
    ...>       "op" => "PUSH1",
    ...>       "pc" => 0,
    ...>       "stack" => []
    ...>     },
    ...>     %{
    ...>       "depth" => 1,
    ...>       "gas" => 599978565,
    ...>       "gasCost" => 3,
    ...>       "op" => "PUSH1",
    ...>       "pc" => 2,
    ...>       "stack" => ["0x80"]
    ...>     },
    ...>     %{
    ...>       "depth" => 1,
    ...>       "gas" => 599978562,
    ...>       "gasCost" => 12,
    ...>       "op" => "MSTORE",
    ...>       "pc" => 4,
    ...>       "stack" => ["0x80", "0x40"]
    ...>     }
    ...>   ]
    ...> }
    ...> |> Cartouche.DebugTrace.deserialize()
    %Cartouche.DebugTrace{
      failed: false,
      gas: 24034,
      return_value: ~h[0x0000000000000000000000000000000000000000000000000858898f93629000],
      struct_logs: [
        %Cartouche.DebugTrace.StructLog{
          depth: 1,
          gas: 599978568,
          gas_cost: 3,
          op: :PUSH1,
          pc: 0,
          stack: []
        },
        %Cartouche.DebugTrace.StructLog{
          depth: 1,
          gas: 599978565,
          gas_cost: 3,
          op: :PUSH1,
          pc: 2,
          stack: [~h[0x80]]
        },
        %Cartouche.DebugTrace.StructLog{
          depth: 1,
          gas: 599978562,
          gas_cost: 12,
          op: :MSTORE,
          pc: 4,
          stack: [~h[0x80], ~h[0x40]]
        }
      ]
    }

# serialize(debug_trace)

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

Serializes a trace result back to a json map.

## Examples

    iex> %Cartouche.DebugTrace{
    ...>   failed: false,
    ...>   gas: 24034,
    ...>   return_value: ~h[0x0000000000000000000000000000000000000000000000000858898f93629000],
    ...>   struct_logs: [
    ...>     %Cartouche.DebugTrace.StructLog{
    ...>       depth: 1,
    ...>       gas: 599978568,
    ...>       gas_cost: 3,
    ...>       op: :PUSH1,
    ...>       pc: 0,
    ...>       stack: []
    ...>     },
    ...>     %Cartouche.DebugTrace.StructLog{
    ...>       depth: 1,
    ...>       gas: 599978565,
    ...>       gas_cost: 3,
    ...>       op: :PUSH1,
    ...>       pc: 2,
    ...>       stack: [~h[0x80]]
    ...>     },
    ...>     %Cartouche.DebugTrace.StructLog{
    ...>       depth: 1,
    ...>       gas: 599978562,
    ...>       gas_cost: 12,
    ...>       op: :MSTORE,
    ...>       pc: 4,
    ...>       stack: [~h[0x80], ~h[0x40]]
    ...>     }
    ...>   ]
    ...> }
    ...> |> Cartouche.DebugTrace.serialize()
    %{
      failed: false,
      gas: 24034,
      returnValue: "0000000000000000000000000000000000000000000000000858898f93629000",
      structLogs: [
        %{
          depth: 1,
          gas: 599978568,
          gasCost: 3,
          op: "PUSH1",
          pc: 0,
          stack: []
        },
        %{
          depth: 1,
          gas: 599978565,
          gasCost: 3,
          op: "PUSH1",
          pc: 2,
          stack: ["0x80"]
        },
        %{
          depth: 1,
          gas: 599978562,
          gasCost: 12,
          op: "MSTORE",
          pc: 4,
          stack: ["0x80", "0x40"]
        }
      ]
    }