Cartouche.Filter (Cartouche v0.8.0)

Copy Markdown View Source

Poll an Ethereum node-side filter and deliver results to registered listeners.

Log filters (kind: :log, the default) decode matching logs and dispatch {:event, {name, params}, log} plus {:log, log}. Block and pending-transaction filters (kind: :block / kind: :pending) dispatch {:hashes, hashes} with 32-byte hash lists. The GenServer uninstalls its node-side filter on shutdown.

Summary

Functions

Returns a specification to start this module under a supervisor.

Registers the calling process as a listener on filter.

Starts a Cartouche.Filter GenServer that polls an Ethereum node-side filter.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

listen(filter)

@spec listen(GenServer.server()) :: :ok

Registers the calling process as a listener on filter.

Log filters send {:event, {name, params}, log} for matched, decoded events and {:log, log} for every raw log. Block and pending filters send {:hashes, hashes} with a list of 32-byte hashes.

start_link(opts \\ [])

@spec start_link(Keyword.t()) :: GenServer.on_start()

Starts a Cartouche.Filter GenServer that polls an Ethereum node-side filter.

Options

  • :name — registered name for the GenServer (defaults to __MODULE__)
  • :kind:log (default), :block, or :pending
  • :address — contract address to filter on (log filters; omit to match any)
  • :topics — list of topic filters (log filters)
  • :events — list of ABI.FunctionSelector.t() or signature strings; events are decoded and dispatched as {:event, {name, params}, log}
  • :rpc_opts — keyword list forwarded to Cartouche.RPC calls
  • :extra_data — opaque value attached to every log/event message
  • :check_delay — milliseconds between filter polls (default 3000)