View Source Signet.Trace (Signet v0.2.0-alpha5)

Represents an Ethereum transaction trace, which contains information about the call graph of an executed transaction.

See Signet.RPC.trace_transaction for getting traces from an Ethereum JSON-RPC host.

See also:

Summary

Functions

Deserializes a single trace result from trace_transction. Note: a JSON-RPC response will return an array of such traces.

Deserializes an array of trace results from trace_transction.

Types

@type t() :: %Signet.Trace{
  action: Signet.Trace.Action.t(),
  block_hash: <<_::256>>,
  block_number: integer(),
  gas_used: integer(),
  output: binary(),
  subtraces: integer(),
  trace_address: <<_::160>>,
  transaction_hash: <<_::256>>,
  transaction_position: integer(),
  type: String.t()
}

Functions

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

Deserializes a single trace result from trace_transction. Note: a JSON-RPC response will return an array of such traces.

Examples

iex> %{
...>   "action" => %{
...>     "callType" => "call",
...>     "from" => "0x83806d539d4ea1c140489a06660319c9a303f874",
...>     "gas" => "0x1a1f8",
...>     "input" => "0x",
...>     "to" => "0x1c39ba39e4735cb65978d4db400ddd70a72dc750",
...>     "value" => "0x7a16c911b4d00000"
...>   },
...>   "blockHash" => "0x7eb25504e4c202cf3d62fd585d3e238f592c780cca82dacb2ed3cb5b38883add",
...>   "blockNumber" => 3068185,
...>   "result" => %{
...>     "gasUsed" => "0x2982",
...>     "output" => "0x"
...>   },
...>   "subtraces" => 2,
...>   "traceAddress" => ["0x1c39ba39e4735cb65978d4db400ddd70a72dc750"],
...>   "transactionHash" => "0x17104ac9d3312d8c136b7f44d4b8b47852618065ebfa534bd2d3b5ef218ca1f3",
...>   "transactionPosition" => 2,
...>   "type" => "call"
...> }
...> |> Signet.Trace.deserialize()
%Signet.Trace{
  action: %Signet.Trace.Action{
    call_type: "call",
    from: Signet.Util.decode_hex!("0x83806d539d4ea1c140489a06660319c9a303f874"),
    gas: 0x01a1f8,
    input: <<>>,
    to: Signet.Util.decode_hex!("0x1c39ba39e4735cb65978d4db400ddd70a72dc750"),
    value: 0x7a16c911b4d00000,
  },
  block_hash: Signet.Util.decode_hex!("0x7eb25504e4c202cf3d62fd585d3e238f592c780cca82dacb2ed3cb5b38883add"),
  block_number: 3068185,
  gas_used: 0x2982,
  output: <<>>,
  subtraces: 2,
  trace_address: [Signet.Util.decode_hex!("0x1c39ba39e4735cb65978d4db400ddd70a72dc750")],
  transaction_hash: Signet.Util.decode_hex!("0x17104ac9d3312d8c136b7f44d4b8b47852618065ebfa534bd2d3b5ef218ca1f3"),
  transaction_position: 2,
  type: "call"
}
Link to this function

deserialize_many(traces)

View Source
@spec deserialize_many([map()]) :: [t()] | no_return()

Deserializes an array of trace results from trace_transction.

Examples

iex> [%{
...>   "action" => %{
...>     "callType" => "call",
...>     "from" => "0x83806d539d4ea1c140489a06660319c9a303f874",
...>     "gas" => "0x1a1f8",
...>     "input" => "0x",
...>     "to" => "0x1c39ba39e4735cb65978d4db400ddd70a72dc750",
...>     "value" => "0x7a16c911b4d00000"
...>   },
...>   "blockHash" => "0x7eb25504e4c202cf3d62fd585d3e238f592c780cca82dacb2ed3cb5b38883add",
...>   "blockNumber" => 3068185,
...>   "result" => %{
...>     "gasUsed" => "0x2982",
...>     "output" => "0x"
...>   },
...>   "subtraces" => 2,
...>   "traceAddress" => ["0x1c39ba39e4735cb65978d4db400ddd70a72dc750"],
...>   "transactionHash" => "0x17104ac9d3312d8c136b7f44d4b8b47852618065ebfa534bd2d3b5ef218ca1f3",
...>   "transactionPosition" => 2,
...>   "type" => "call"
...> }]
...> |> Signet.Trace.deserialize_many()
[
  %Signet.Trace{
    action: %Signet.Trace.Action{
      call_type: "call",
      from: Signet.Util.decode_hex!("0x83806d539d4ea1c140489a06660319c9a303f874"),
      gas: 0x01a1f8,
      input: <<>>,
      to: Signet.Util.decode_hex!("0x1c39ba39e4735cb65978d4db400ddd70a72dc750"),
      value: 0x7a16c911b4d00000,
    },
    block_hash: Signet.Util.decode_hex!("0x7eb25504e4c202cf3d62fd585d3e238f592c780cca82dacb2ed3cb5b38883add"),
    block_number: 3068185,
    gas_used: 0x2982,
    output: <<>>,
    subtraces: 2,
    trace_address: [Signet.Util.decode_hex!("0x1c39ba39e4735cb65978d4db400ddd70a72dc750")],
    transaction_hash: Signet.Util.decode_hex!("0x17104ac9d3312d8c136b7f44d4b8b47852618065ebfa534bd2d3b5ef218ca1f3"),
    transaction_position: 2,
    type: "call"
  }
]