eth_event v0.1.1 EthEvent.Api.Balance View Source

Defines the Balance event.

In order to request a Balance, you have to specify the desired address and block_number (defaults to "latest") by setting it in the event struct itself e.g:

> alias EthEvent.Api.Balance
> {:ok, %Balance{} = balance} = Balance.query(%Balance{address: "0x93e..."})
> balance
%Balance{
  address: "0x93ecb3962981e1ba2928297cb09c1932aa2c9c51",
  block_hash: "0xb7381ade07e036e0f9195446f54b6c5e6228a10d3ff750ded(...)",
  balance: 100000000000000000000, # In Wei
  ...
}

This event can be composed with other events as long as address and (optionally block_number) are present in the other event e.g:

> alias EthEvent.Api.{Block, Balance}
> Block.query!() |> Balance.query!(address: "0x93e...")
%Balance{
  address: "0x93ecb3962981e1ba2928297cb09c1932aa2c9c51",
  block_hash: "0xb7381ade07e036e0f9195446f54b6c5e6228a10d3ff750ded(...)",
  block_number: 1234,
  type: "mined",
  balance: 100000000000000000000, # In Wei
  ...
}

Link to this section Summary

Functions

Builds the query to get the balance of an account. It receives the an event. some initial parameters and some options as Keyword list

Decodes the result from the Balance event query and places it in the Balance struct

Link to this section Functions

Link to this function build_query(event, options) View Source
build_query(EthEvent.Schema.t(), Keyword.t()) ::
  {:ok, term()} | {:error, term()}

Builds the query to get the balance of an account. It receives the an event. some initial parameters and some options as Keyword list.

Link to this function build_result(event, result) View Source
build_result(EthEvent.Schema.t(), term()) ::
  {:ok, EthEvent.Schema.t()} | {:error, term()}

Decodes the result from the Balance event query and places it in the Balance struct.

Link to this function query(event \\ [], options \\ []) View Source
Link to this function query!(event \\ [], options \\ []) View Source