|
| 1 | +# purescript-hydra-sdk |
| 2 | + |
| 3 | +[Cardano Hydra](https://hydra.family/head-protocol/) |
| 4 | +SDK (Software Development Kit) for PureScript. This library offers |
| 5 | +various interfaces to facilitate rapid development of Hydra-based |
| 6 | +applications. |
| 7 | + |
| 8 | +**Table of Contents** |
| 9 | + |
| 10 | +<!-- START doctoc generated TOC please keep comment here to allow auto update --> |
| 11 | +<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> |
| 12 | + |
| 13 | +- [Applications](#applications) |
| 14 | +- [Functionality](#functionality) |
| 15 | +- [Development Workflows](#development-workflows) |
| 16 | + |
| 17 | +<!-- END doctoc generated TOC please keep comment here to allow auto update --> |
| 18 | + |
| 19 | +### Applications |
| 20 | + |
| 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. |
| 23 | + |
| 24 | +### Functionality |
| 25 | + |
| 26 | +The `HydraSdk.Process` module provides an interface for spinning up a hydra-node |
| 27 | +as a Node.js subprocess. |
| 28 | + |
| 29 | +The `HydraSdk.NodeApi` module exports functions for connecting to the Hydra Node |
| 30 | +WebSocket API and sending HTTP requests. The primary function provided by this |
| 31 | +module is `mkHydraNodeApiWebSocket`, which establishes a WebSocket connection to |
| 32 | +the hydra-node, attaches specified handlers for incoming messages, and returns a |
| 33 | +`HydraNodeApiWebSocket` record with type-safe actions for interacting with the |
| 34 | +Hydra Node API. It also allows to specify retry strategies for Hydra |
| 35 | +transactions that may be silently dropped by cardano-node, particularly for |
| 36 | +Close and Contest transactions. |
| 37 | + |
| 38 | +The `HydraSdk.Types` module re-exports various Hydra domain-specific types |
| 39 | +(such as `HydraHeadStatus` and `HydraNodeApi_InMessage`), along with other |
| 40 | +utility types (e.g., `HostPort` and `Network`) used by the components of this |
| 41 | +library. |
| 42 | + |
| 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). |
| 47 | + |
| 48 | +### Development Workflows |
| 49 | + |
| 50 | +Before executing most of the commands listed below, first enter the Nix |
| 51 | +development shell by running `nix develop`. |
| 52 | + |
| 53 | +**Build the project** (requires Nix shell): `make build` |
| 54 | +**Format code** (requires Nix shell): `make format` |
| 55 | +**Build docs and open them in the browser**: `make docs` |
0 commit comments