Steemex
Elixir websockets client for steemd. Provides an interface to Steem JSONRPC protocol. Steemex is now a supervised application with two workers and a configurable handler for responses to JSONRPC calls.
Steemex is under active development.
Installation
- Add
steemexto your list of dependencies inmix.exs:
```elixir
def deps do
[{:steemex, "~> 0.1.0"}]
end
```
- Add 'steemex' to applications in
mix.exs:elixir def application do [applications: [:logger, :steemex]] end
Example
First, configure a websockets url for the steemd instance, for example, http://127.0.0.1:8090 to the config.
Then, provide a handler module in the config file.
config :steemex,
url: "STEEM_URL",
handler: SteemexHandlerModule
Example of SteemexHandlerModule. You need a handler module with a handle_jsonrpc_call callback. GenServer handler implementation is recommended as any advanced aggregation or analysis of blockchain data requires some state management.
defmodule Steemex.Handler do
use GenServer
require Logger
def start_link(_params \\ []) do
GenServer.start_link(__MODULE__, [])
end
def handle_jsonrpc_call(id, call_params, data) do
GenServer.cast(__MODULE__, {id, call_params, data} )
end
def handle_cast({["database_api", "get_dynamic_global_properties", []], data}, _) do
Logger.debug inspect(data)
{:noreply, []}
end
def handle_cast({msg_name, _}, _) do
Logger.debug("No known handler function for this message #{msg_name}")
{:noreply, []}
end
end
Roadmap
Supervisor and option for a developer to provide handler process in the config- Utility functions
- Add types and structs
- More tests and docs