Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
/.spago/
/.spago2nix/
.psc-ide-port
blockfrost.txt
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and we follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [[Unreleased]](#unreleased)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## [Unreleased]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ format: requires-nix-shell
@echo -e '\n3. Formatting Nix sources:'
nixpkgs-fmt ${nix-sources}
@echo -e '\n4. Generating table of contents for Markdown files:'
doctoc README.md --github --notitle
doctoc README.md CHANGELOG.md --github --notitle

repl: requires-nix-shell
spago repl
Expand Down
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ of Hydra-based applications.

| hydra-sdk | hydra-node | cardano-node |
| ----------- | ------------ | ------------ |
| **`0.1.0`** | **`0.19.0`** | **`10.1.2`** |
| **`1.0.0`** | **`0.19.0`** | **`10.1.2`** |
| **`2.0.0`** | **`1.2.0`** | **`10.5.3`** |


## Preliminaries
Expand Down Expand Up @@ -56,11 +57,13 @@ a cluster of two nodes, with each node running the minimal example logic.
directory of this repository. This will put you in the shell with all the
necessary executables required to continue with the setup procedure.

2. In [example/minimal/docker/cluster/](example/minimal/docker/cluster/) you
can find configuration files for both nodes. The only field that needs to be
updated here is the `blockfrostApiKey`, which should be set to a valid
Blockfrost API key **for preprod**.
Visit the [Blockfrost website](https://blockfrost.io/) to generate a fresh API key.
2. Run `touch example/minimal/blockfrost.txt` to create a text file that will
store your Blockfrost API key. Visit the
[Blockfrost website](https://blockfrost.io/) to generate a new API key for the
**preprod** network and paste it into this file. In the directory
[example/minimal/docker/cluster/](example/minimal/docker/cluster/), you will
find configuration files for both nodes. No changes are required here to start a
functioning Hydra cluster, though you may adjust some settings if needed.

3. Execute `make gen-keys` to generate the necessary Cardano and Hydra keys
required by the underlying Hydra nodes. Cardano keys are used to authenticate
Expand Down Expand Up @@ -167,4 +170,4 @@ for hydra-auction-offchain and hopefully other Hydra applications.
## Applications

Please refer to [hydra-auction-offchain](https://github.com/mlabs-haskell/hydra-auction-offchain)
for a full-fledged example that utilizes this SDK.
for a full-fledged example that utilizes this SDK.
6 changes: 3 additions & 3 deletions example/minimal/app/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Prelude

import Aeson (stringifyAeson)
import Cardano.AsCbor (decodeCbor, encodeCbor)
import Cardano.Types (Language(PlutusV2), Transaction)
import Cardano.Types (Language(PlutusV3), Transaction)
import Cardano.Types.AuxiliaryData (hashAuxiliaryData)
import Cardano.Types.Transaction (_body, _witnessSet)
import Cardano.Types.TransactionBody (_auxiliaryDataHash)
Expand Down Expand Up @@ -185,7 +185,7 @@ messageHandler ws =
setUtxoSnapshot $ HydraSnapshot
{ snapshotNumber: zero
, utxo
, confirmedTransactions: mempty
, confirmed: mempty
}
tx <- runContractInApp $ placeArbitraryDatumL2 $ toUtxoMap utxo
liftEffect $ ws.submitTxL2 tx
Expand Down Expand Up @@ -224,7 +224,7 @@ fixCommitTx = reSignTransaction <=< fixScriptIntegrityHash <<< setAuxDataHash
fixScriptIntegrityHash tx = do
pparams <- unwrap <$> getProtocolParameters
let
costModels = Map.filterKeys (eq PlutusV2) pparams.costModels
costModels = Map.filterKeys (eq PlutusV3) pparams.costModels
ws = unwrap (unwrap tx).witnessSet
liftEffect $ setScriptDataHash costModels ws.redeemers ws.plutusData tx

Expand Down
22 changes: 15 additions & 7 deletions example/minimal/docker/cluster/config-a.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,26 @@
"hydraNodeStartupParams": {
"nodeId": "1063b00f-0d5b-46b6-9aff-88114a25f688",
"hydraNodeAddress": "0.0.0.0:7000",
"hydraNodeAdvertisedAddress": "delegate-node-a:7000",
"hydraNodeApiAddress": "127.0.0.1:7001",
"persistDir": "hydra-persist",
"hydraSigningKey": "keys/hydra-a.sk",
"cardanoSigningKey": "keys/cardano-a.sk",
"network": {
"tag": "Testnet",
"magic": 1
"queryLayer": {
"tag": "CardanoNode",
"nodeSocket": "node-ipc/node.socket",
"network": {
"tag": "Testnet",
"magic": 1
}
},
"nodeSocket": "node-ipc/node.socket",
"pparams": "protocol-parameters.json",
"hydraScriptsTxHash": "03f8deb122fbbd98af8eb58ef56feda37728ec957d39586b78198a0cf624412a",
"contestPeriodSec": 120,
"hydraScripts": [
"ba97aaa648271c75604e66e3a4e00da49bdcaca9ba74d9031ab4c08f736e1c12",
"ff046eba10b9b0f90683bf5becbd6afa496059fc1cf610e798cfe778d85b70ba",
"4bb8c01290599cc9de195b586ee1eb73422b00198126f51f52b00a8e35da9ce3"
],
"contestPeriodSec": 60,
"peers": [
{
"hydraNodeAddress": "delegate-node-b:7002",
Expand All @@ -22,7 +30,7 @@
}
]
},
"blockfrostApiKey": null,
"blockfrostApiKeyFile": "blockfrost.txt",
"logLevel": "trace",
"ctlLogLevel": "warn",
"commitOutRef": null
Expand Down
22 changes: 15 additions & 7 deletions example/minimal/docker/cluster/config-b.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,26 @@
"hydraNodeStartupParams": {
"nodeId": "91fd9af9-1eb8-42e7-8cb3-20bca7a4f13b",
"hydraNodeAddress": "0.0.0.0:7002",
"hydraNodeAdvertisedAddress": "delegate-node-b:7002",
"hydraNodeApiAddress": "127.0.0.1:7003",
"persistDir": "hydra-persist",
"hydraSigningKey": "keys/hydra-b.sk",
"cardanoSigningKey": "keys/cardano-b.sk",
"network": {
"tag": "Testnet",
"magic": 1
"queryLayer": {
"tag": "CardanoNode",
"nodeSocket": "node-ipc/node.socket",
"network": {
"tag": "Testnet",
"magic": 1
}
},
"nodeSocket": "node-ipc/node.socket",
"pparams": "protocol-parameters.json",
"hydraScriptsTxHash": "03f8deb122fbbd98af8eb58ef56feda37728ec957d39586b78198a0cf624412a",
"contestPeriodSec": 120,
"hydraScripts": [
"ba97aaa648271c75604e66e3a4e00da49bdcaca9ba74d9031ab4c08f736e1c12",
"ff046eba10b9b0f90683bf5becbd6afa496059fc1cf610e798cfe778d85b70ba",
"4bb8c01290599cc9de195b586ee1eb73422b00198126f51f52b00a8e35da9ce3"
],
"contestPeriodSec": 60,
"peers": [
{
"hydraNodeAddress": "delegate-node-a:7000",
Expand All @@ -22,7 +30,7 @@
}
]
},
"blockfrostApiKey": null,
"blockfrostApiKeyFile": "blockfrost.txt",
"logLevel": "trace",
"ctlLogLevel": "warn",
"commitOutRef": null
Expand Down
2 changes: 1 addition & 1 deletion example/minimal/docker/cluster/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
cardano-node:
image: ghcr.io/intersectmbo/cardano-node:10.1.3
image: ghcr.io/intersectmbo/cardano-node:10.5.3
environment:
- NETWORK=preprod
volumes:
Expand Down
8 changes: 6 additions & 2 deletions example/minimal/docker/node/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@ RUN npm install purescript@0.15.8
RUN npm install spago@0.21.0

COPY example/minimal/packages.dhall example/minimal/spago.dhall .
RUN wget -O package-set.dhall "$(grep -oP 'https://raw[^ ]+' packages.dhall)"
RUN sed -i 's|https://raw[^ ]*|./package-set.dhall|' packages.dhall
RUN npx --no-install spago install

COPY example/minimal/src src
COPY example/minimal/app app
COPY example/minimal/protocol-parameters.json .
COPY example/minimal/blockfrost.txt .
RUN npx --no-install spago build

RUN curl -LO https://github.com/input-output-hk/hydra/releases/download/0.19.0/hydra-x86_64-linux-0.19.0.zip
RUN unzip -d /usr/local/bin/ hydra-x86_64-linux-0.19.0.zip
ARG HYDRA_VERSION=1.2.0
RUN curl -LO https://github.com/input-output-hk/hydra/releases/download/${HYDRA_VERSION}/hydra-x86_linux-${HYDRA_VERSION}.zip
RUN unzip -d /usr/local/bin/ hydra-x86_linux-${HYDRA_VERSION}.zip
RUN chmod +x /usr/local/bin/hydra-node

ENTRYPOINT ["npx", "--no-install", "spago", "-q", "run", "--main", "HydraSdk.Example.Minimal.Main", "--exec-args"]
Expand Down
Loading