Search documentation of Cartouche

# Cartouche.Filter (Cartouche v0.1.2)

Copy Markdown View Source

A system to create an Ethereum log filter and have parsed events passed back to registered processes.

## Summary

### Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

listen(filter)

Registers the calling process as a listener on `filter`. The filter will send `{:event, {name, params}, log}` for matched, decoded events and `{:log, log}` for every raw log it receives.

start_link(opts \\ [])

Starts a Cartouche.Filter GenServer that polls Ethereum logs matching the given filter and forwards parsed events to registered listeners.

## 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`. The filter will send `{:event, {name, params}, log}` for matched, decoded events and `{:log, log}` for every raw log it receives.

# start_link(opts \\ [])

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

Starts a Cartouche.Filter GenServer that polls Ethereum logs matching the given filter and forwards parsed events to registered listeners.

## Options

- `:name` — registered name for the GenServer (defaults to `__MODULE__`)
- `:address` — contract address to filter on (omit to match any)
- `:topics` — list of topic 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)