Onchain.Filter.Log (onchain v0.16.0)

Copy Markdown View Source

A decoded Ethereum log entry.

Produced by Onchain.Filter for kind: :log filters and returned by Onchain.RPC.eth_get_logs/2, Onchain.RPC.get_filter_logs/2, and Onchain.Receipt logs, and subscription notifications. :removed is nil when omitted by the node. Pending logs may omit or null their block and transaction location fields; these decode to nil. Addresses, hashes, and topics are decoded to raw binaries; :block_number, :log_index, and :transaction_index to integers. :extra_data is the opaque term a Onchain.Filter was started with, stamped onto every log it dispatches, and is nil elsewhere.

API Functions

FunctionArityDescriptionParam Kinds
deserialize1Deserialize an Ethereum transaction receipt log from a JSON-RPC object.params: exchange_data

Summary

Functions

Deserializes a transaction receipt as serialized by an Ethereum JSON-RPC response.

Types

t()

@type t() :: %Onchain.Filter.Log{
  address: binary(),
  block_hash: binary() | nil,
  block_number: non_neg_integer() | nil,
  data: binary(),
  extra_data: term(),
  log_index: non_neg_integer() | nil,
  removed: boolean() | nil,
  topics: [binary()],
  transaction_hash: binary() | nil,
  transaction_index: non_neg_integer() | nil
}

Functions

deserialize(params)

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

Deserializes a transaction receipt as serialized by an Ethereum JSON-RPC response.

See also https://ethereum.org/en/developers/docs/apis/json-rpc#eth_gettransactionreceipt

Examples

iex> use Onchain.Hex
iex> %{
...>   "logIndex" => "0x1",
...>   "blockNumber" => "0x1b4",
...>   "blockHash" => "0xa957d47df264a31badc3ae823e10ac1d444b098d9b73d204c40426e57f47e8c3",
...>   "transactionHash" =>  "0xaadf829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf",
...>   "transactionIndex" => "0x0",
...>   "address" => "0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d",
...>   "data" => "0x0000000000000000000000000000000000000000000000000000000000000000",
...>   "topics" => [
...>     "0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5"
...>   ]
...> }
...> |> Onchain.Filter.Log.deserialize()
%Onchain.Filter.Log{
  log_index: 1,
  block_number: 0x01b4,
  block_hash: ~h[0xa957d47df264a31badc3ae823e10ac1d444b098d9b73d204c40426e57f47e8c3],
  transaction_hash: ~h[0xaadf829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf],
  transaction_index: 0,
  address: ~h[0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d],
  data: ~h[0x0000000000000000000000000000000000000000000000000000000000000000],
  topics: [
    ~h[0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5]
  ]
}