View Source Signet.DebugTrace (Signet v1.3.8)

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 Signet.RPC.debug_trace_call for getting traces from an Ethereum JSON-RPC host.

See also:

Summary

Functions

Deserializes a trace result from debug_traceCall.

Serializes a trace result back to a json map.

Types

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

Functions

@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"]
...>     }
...>   ]
...> }
...> |> Signet.DebugTrace.deserialize()
%Signet.DebugTrace{
  failed: false,
  gas: 24034,
  return_value: ~h[0x0000000000000000000000000000000000000000000000000858898f93629000],
  struct_logs: [
    %Signet.DebugTrace.StructLog{
      depth: 1,
      gas: 599978568,
      gas_cost: 3,
      op: :PUSH1,
      pc: 0,
      stack: []
    },
    %Signet.DebugTrace.StructLog{
      depth: 1,
      gas: 599978565,
      gas_cost: 3,
      op: :PUSH1,
      pc: 2,
      stack: [~h[0x80]]
    },
    %Signet.DebugTrace.StructLog{
      depth: 1,
      gas: 599978562,
      gas_cost: 12,
      op: :MSTORE,
      pc: 4,
      stack: [~h[0x80], ~h[0x40]]
    }
  ]
}
@spec serialize(t()) :: map()

Serializes a trace result back to a json map.

Examples

iex> %Signet.DebugTrace{
...>   failed: false,
...>   gas: 24034,
...>   return_value: ~h[0x0000000000000000000000000000000000000000000000000858898f93629000],
...>   struct_logs: [
...>     %Signet.DebugTrace.StructLog{
...>       depth: 1,
...>       gas: 599978568,
...>       gas_cost: 3,
...>       op: :PUSH1,
...>       pc: 0,
...>       stack: []
...>     },
...>     %Signet.DebugTrace.StructLog{
...>       depth: 1,
...>       gas: 599978565,
...>       gas_cost: 3,
...>       op: :PUSH1,
...>       pc: 2,
...>       stack: [~h[0x80]]
...>     },
...>     %Signet.DebugTrace.StructLog{
...>       depth: 1,
...>       gas: 599978562,
...>       gas_cost: 12,
...>       op: :MSTORE,
...>       pc: 4,
...>       stack: [~h[0x80], ~h[0x40]]
...>     }
...>   ]
...> }
...> |> Signet.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"]
    }
  ]
}