Search documentation of Cartouche

# Cartouche.Receipt.Log (Cartouche v0.1.2)

Copy Markdown View Source

An event log entry emitted during the transaction referenced by a `Cartouche.Receipt` — address, data, indexed topics, and the block/tx position needed to locate the log on chain.

## Summary

### Types

t()

### Functions

deserialize(params)

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

## Types

# t()

    @type t() :: %Cartouche.Receipt.Log{
      address: <<_::160>>,
      block_hash: <<_::256>>,
      block_number: integer(),
      data: binary(),
      log_index: integer(),
      topics: [<<_::256>>],
      transaction_hash: <<_::256>>,
      transaction_index: integer()
    }

## Functions

# deserialize(params)

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

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 Cartouche.Hex
    iex> %{
    ...>   "logIndex" => "0x1",
    ...>   "blockNumber" => "0x1b4",
    ...>   "blockHash" => "0xa957d47df264a31badc3ae823e10ac1d444b098d9b73d204c40426e57f47e8c3",
    ...>   "transactionHash" =>  "0xaadf829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf",
    ...>   "transactionIndex" => "0x0",
    ...>   "address" => "0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d",
    ...>   "data" => "0x0000000000000000000000000000000000000000000000000000000000000000",
    ...>   "topics" => [
    ...>     "0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5"
    ...>   ]
    ...> }
    ...> |> Cartouche.Receipt.Log.deserialize()
    %Cartouche.Receipt.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]
      ]
    }