Skip to content

Commit

Permalink
Update docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
caike committed Aug 12, 2024
1 parent ad17c2c commit 77a9e4c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,29 @@ ChainSync mini-protocol:

A new file should be created at _./lib/my_app/chain_sync_client.ex_

```elixir
defmodule MyApp.ChainSyncClient do
@moduledoc """
This module syncs with the chain and reads new blocks
as they become available.
"""

use Xogmios, :chain_sync

def start_link(opts) do
initial_state = []
opts = Keyword.merge(opts, initial_state)
Xogmios.start_chain_sync_link(__MODULE__, opts)
end

@impl true
def handle_block(block, state) do
IO.puts("handle_block #{block["height"]}")
{:ok, :next_block, state}
end
end
```

Add this new module to your application's supervision tree as such:

```elixir
Expand All @@ -64,6 +87,8 @@ def start(_type, _args) do
end
```

Be sure the env `OGMIOS_URL` is populated and then start your mix application.

The value for the `url` option should be set to the address of your Ogmios instance.

If you don't have access to an Ogmios endpoint, you can use https://demeter.run/ and start one for free.
Expand Down
3 changes: 2 additions & 1 deletion lib/mix/tasks/xogmios.gen.client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ defmodule Mix.Tasks.Xogmios.Gen.Client do
"""
defmodule <%= @app_module_name %>.<%= @client_module_name %> do
@moduledoc \"\"\"
This module syncs with the chain and reads new blocks.
This module syncs with the chain and reads new blocks
as they become available.
Be sure to add this module to your app's supervision tree like so:
Expand Down

0 comments on commit 77a9e4c

Please sign in to comment.