Skip to content

Commit 08a52e6

Browse files
authored
chore:Add Quickstart to README (#69)
1 parent 4282d33 commit 08a52e6

1 file changed

Lines changed: 32 additions & 1 deletion

File tree

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,38 @@ Mini-Protocols supported by this library:
2525

2626
See [Examples](#examples) section below for information on how to use this library.
2727

28-
## Installation
28+
## Quick Start
29+
30+
```elixir
31+
Mix.install([{:xogmios, "> 0.0.0"}])
32+
33+
defmodule ChainSyncClient do
34+
use Xogmios, :chain_sync
35+
36+
def start_link(opts) do
37+
Xogmios.start_chain_sync_link(__MODULE__, opts)
38+
end
39+
40+
@impl true
41+
def handle_block(block, state) do
42+
IO.puts(block["height"])
43+
{:ok, :next_block, state}
44+
end
45+
end
46+
47+
opts = [
48+
# Populate OGMIOS_URL with your Ogmios Server WS URL
49+
# or use https://demeter.run/
50+
url: System.fetch_env!("OGMIOS_URL"),
51+
sync_from: :origin
52+
]
53+
54+
{:ok, _pid} = ChainSyncClient.start_link(opts)
55+
56+
Process.sleep(:infinity)
57+
```
58+
59+
## Using it on a mix project
2960

3061
Add the dependency to `mix.exs`:
3162

0 commit comments

Comments
 (0)