You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
18
22
19
-
### Applications
23
+
##Compatibility
20
24
21
-
Please refer to [hydra-auction-offchain](https://github.com/mlabs-haskell/hydra-auction-offchain)
22
-
for a full-fledged example that utilizes this SDK.
25
+
| hydra-sdk | hydra-node | cardano-node |
26
+
| ----------- | ------------ | ------------ |
27
+
|**`0.1.0`**|**`0.19.0`**|**`10.1.2`**|
28
+
29
+
30
+
## Preliminaries
31
+
32
+
Since using this SDK implies a certain degree of understanding of the Hydra
33
+
protocol, it is advisable to get familiar with the ["Hydra: Fast Isomorphic State Channels" paper](https://iohk.io/en/research/library/papers/hydra-fast-isomorphic-state-channels/)
34
+
and the [Hydra Head protocol documentation](https://hydra.family/head-protocol/docs/)
35
+
before proceeding with the **Getting Started** guide below.
36
+
37
+
## Development Workflows
38
+
39
+
Before executing most of the commands listed below, first enter the Nix
40
+
development shell by running `nix develop`.
41
+
42
+
***Build docs and open them in the browser**: `make docs`
43
+
***Build the project**: `make build`
44
+
***Format code**: `make format`
45
+
46
+
## Getting Started with Example
47
+
48
+
The simplest way to get a sense of how this SDK can help build Hydra-based
49
+
applications is to run our minimal example and then adapt or extend it to suit
50
+
your specific requirements.
51
+
52
+
Go to `example/minimal` and follow the step-by-step guide below to spin up
53
+
a cluster of two nodes, with each node running the minimal example logic.
54
+
55
+
1. Enter the Nix development environment by running `nix develop` from the root
56
+
directory of this repository. This will put you in the shell with all the
57
+
necessary executables required to continue with the setup procedure.
23
58
24
-
### Functionality
59
+
2. In [example/minimal/docker/cluster/](example/minimal/docker/cluster/) you
60
+
can find configuration files for both nodes. The only field that needs to be
61
+
updated here is the `blockfrostApiKey`, which should be set to a valid
62
+
Blockfrost API key **for preprod**.
63
+
Visit the [Blockfrost website](https://blockfrost.io/) to generate a fresh API key.
25
64
26
-
The `HydraSdk.Process` module provides an interface for spinning up a hydra-node
65
+
3. Execute `make gen-keys` to generate the necessary Cardano and Hydra keys
66
+
required by the underlying Hydra nodes. Cardano keys are used to authenticate
67
+
on-chain transactions, while the Hydra keys are used for multi-signing snapshots
68
+
within a Hydra Head. This command will output two Cardano preprod addresses
69
+
that must be pre-funded with sufficient tADA to run properly functioning Hydra
70
+
nodes.
71
+
Use the [Testnets faucet](https://docs.cardano.org/cardano-testnets/tools/faucet/)
72
+
to request tADA.
73
+
74
+
4. Finally, execute `make run-example` to launch a Hydra Head
75
+
with two participants both running the minimal example logic.
76
+
77
+
NOTE: Hydra nodes require a fully synchronized Cardano node to operate
78
+
correctly. No additional setup actions need to be performed to
79
+
configure the Cardano node as it is already included in the Docker
80
+
Compose configuration.
81
+
However, node synchronization may take several hours on the first run.
82
+
Keep in mind that Hydra nodes are configured to run only once
83
+
the Cardano node is fully synchronized,
84
+
and the `cardano-node` output is suppressed to not
85
+
interfere with useful Hydra Head logs.
86
+
As a result, there will be no output during synchronization.
87
+
Instead, use `docker logs` or run `cardano-cli query tip`
88
+
from within the `cardano-node` Docker container
89
+
to track the synchronization progress.
90
+
91
+
## SDK Core Functionality
92
+
93
+
The SDK exposes the following top-level modules which constitus it API which
94
+
is considered to be relatvely stable. You also can use `Internal` modules
95
+
at yor own risk.
96
+
97
+
*`HydraSdk.Process` module provides an interface for spinning up a hydra-node
27
98
as a Node.js subprocess.
28
99
29
-
The`HydraSdk.NodeApi` module exports functions for connecting to the Hydra Node
100
+
*`HydraSdk.NodeApi` module exports functions for connecting to the Hydra Node
30
101
WebSocket API and sending HTTP requests. The primary function provided by this
31
102
module is `mkHydraNodeApiWebSocket`, which establishes a WebSocket connection to
32
103
the hydra-node, attaches specified handlers for incoming messages, and returns a
@@ -35,21 +106,65 @@ Hydra Node API. It also allows to specify retry strategies for Hydra
35
106
transactions that may be silently dropped by cardano-node, particularly for
36
107
Close and Contest transactions.
37
108
38
-
The`HydraSdk.Types` module re-exports various Hydra domain-specific types
109
+
*`HydraSdk.Types` module re-exports various Hydra domain-specific types
39
110
(such as `HydraHeadStatus` and `HydraNodeApi_InMessage`), along with other
40
111
utility types (e.g., `HostPort` and `Network`) used by the components of this
41
112
library.
42
113
43
-
`HydraSdk.Extra.AppManager` provides an opinionated interface for managing
44
-
multiple Hydra application instances, with each instance running a separate
45
-
hydra-node process, as implemented in [hydra-auction-offchain](https://github.com/mlabs-haskell/hydra-auction-offchain).
46
-
For more information, refer to the [AppManager README](src/Extra/README.md).
114
+
* Lastly, `HydraSdk.Lib` module contains useful helpers like codecs for many types,
115
+
logging action and some others.
47
116
48
-
### Development Workflows
117
+
##SDK Additionals: AppManager
49
118
50
-
Before executing most of the commands listed below, first enter the Nix
51
-
development shell by running `nix develop`.
119
+
Under `Extra` folder, modules with additional functionality are located,
120
+
currently being the only one for managing multiple app instances.
52
121
53
-
**Build the project** (requires Nix shell): `make build`
0 commit comments