Skip to content

Commit 8ec990d

Browse files
committed
Fix some commands after testing
1 parent da499b5 commit 8ec990d

File tree

8 files changed

+38
-13
lines changed

8 files changed

+38
-13
lines changed

docs/docs/how-to/commit-blueprint.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ cardano-cli query protocol-parameters \
9393
--testnet-magic 1 \
9494
--socket-path testnets/preprod/node.socket \
9595
--out-file pp-preprod.json
96-
9796
```
9897

9998
## Step 5
@@ -127,7 +126,7 @@ Press `i` to initialize the `head`. Once the head is in the `Initializing` state
127126

128127
This is the valid JSON request:
129128

130-
```shell
129+
```json
131130
{
132131
"blueprintTx": {
133132
"cborHex": "84a3008182582014ab373afb1112d925b0f6a84518ac26d4a8cfcc99231e1f47e6996182e843a900018182581d6069830961c6af9095b0f2648dff31fa9545d8f0b6623db865eb78fde81a007a12000200a0f5f6",

docs/docs/how-to/commit-script-utxo.md

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ sidebar_position: 2
66

77
This guide provides a walkthrough on how to commit a UTxO from a script into a Hydra Head.
88

9+
A **Script UTxO** is a special kind of Unspent Transaction Output (UTxO) that isn't controlled by a simple private key. Instead, it's locked by a script—a small program that runs on the blockchain. To spend the funds in a Script UTxO, you must provide data (a "redeemer" and "datum") that satisfies the conditions defined in that script.
10+
11+
Committing a script UTxO to a Hydra Head is a powerful feature that allows for more complex on-chain validation logic to be brought into the Head. This is useful for scenarios where you need to enforce specific rules on how funds can be spent, even within the Head's off-chain environment.
12+
13+
This tutorial will guide you through the entire process, which involves creating a script, locking an on-chain UTxO with it, and then preparing a special "blueprint" transaction to commit this script UTxO into an open Head.
14+
915
## Prerequisites
1016

1117
This tutorial assumes you are familiar with the process of committing a standard UTxO to a Hydra Head. If you are not, please first read the [Commit using a blueprint](./commit-blueprint.md) tutorial.
@@ -60,19 +66,35 @@ cardano-cli query utxo \
6066
--socket-path testnets/preprod/node.socket
6167
```
6268

63-
Pick a UTxO from the output and use it to build a transaction that sends funds to the script address. Let's say you picked a UTxO with TxHash `a5a11c..` and index `0` containing `100 ADA`. We'll send `10 ADA` to the script address:
69+
Pick a UTxO from the output and use it to build a transaction that sends funds to the script address. Let's say you picked a UTxO with TxHash `<UTXO_TXIX>` containing `100 ADA`. We'll send `10 ADA` to the script address.
70+
71+
First, create a file named `datum.json` that contains the datum. For this example, we will just use the integer `42`.
72+
73+
```json
74+
{
75+
"constructor": 0,
76+
"fields": [
77+
{
78+
"int": 42
79+
}
80+
]
81+
}
82+
```
83+
84+
Now, build the transaction:
6485

6586
```shell
6687
cardano-cli conway transaction build \
6788
--tx-in <UTXO_TXIX> \
6889
--tx-out $(cat script.addr)+10000000 \
69-
--tx-out-datum-embed-value 42 \
90+
--tx-out-inline-datum-file datum.json \
7091
--change-address $(cardano-cli address build --payment-verification-key-file hydra-cluster/config/credentials/alice-funds.vk --testnet-magic 1) \
7192
--testnet-magic 1 \
7293
--socket-path testnets/preprod/node.socket \
7394
--out-file tx.raw
7495
```
75-
Note that we are also providing a datum value `42`. Even though our script does not use it, a datum is required for all script UTxOs.
96+
97+
Note that we are also providing an inline datum via the `datum.json` file. Even though our script does not use it, a datum is required for all script UTxOs.
7698

7799
Now, sign and submit the transaction:
78100

@@ -101,19 +123,23 @@ cardano-cli query utxo \
101123

102124
Now we are ready to prepare the commit. We'll create a blueprint transaction that spends the script UTxO. Note that this transaction is not meant to be signed and submitted to the Cardano network. It's just a blueprint that we'll send to the `hydra-node` to get a properly drafted commit transaction.
103125

126+
We use `cardano-cli ... build-raw` to construct this blueprint because it gives us full control over the transaction structure without trying to automatically balance it or calculate fees, which is perfect for a blueprint.
127+
104128
In this transaction, we'll spend the script UTxO and send the funds to our own wallet address.
105129

106130
```shell
107131
cardano-cli conway transaction build-raw \
108132
--tx-in <SCRIPT_UTXO_TXIX> \
109133
--tx-in-script-file always-true.plutus \
110134
--tx-in-datum-value 42 \
111-
--tx-in-reedeemer-value 42 \
135+
--tx-in-redeemer-value 42 \
136+
--tx-in-execution-units '(0, 0)' \
112137
--tx-out $(cardano-cli address build --payment-verification-key-file hydra-cluster/config/credentials/alice-funds.vk --testnet-magic 1)+10000000 \
113138
--fee 0 \
114139
--out-file tx.json
115140
```
116-
As you can see, we are providing the script file, the datum, and a redeemer. Our "always-true" script doesn't actually check any of these, but they are required for a valid transaction spending a script UTxO.
141+
142+
A real-world script, like one written in [Aiken](https://aiken-lang.org/), would use the datum to carry state and the redeemer to provide input for validation. Our "always-true" script doesn't actually check any of these, but they are still required fields for a valid transaction that spends a script UTxO. Note that we also provide `--tx-in-execution-units`. This is required for any script spend to tell the network how much computational resource to budget for the script's execution. Since our script does nothing, we can use `(0, 0)`.
117143

118144
## Step 5: Commit the script UTxO
119145

docs/docs/how-to/incremental-commit.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 4
2+
sidebar_position: 5
33
---
44

55
# Commit funds to an open Head

docs/docs/how-to/incremental-decommit.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 5
2+
sidebar_position: 6
33
---
44

55
# Decommit funds

docs/docs/how-to/operating-hydra.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 6
2+
sidebar_position: 7
33
---
44

55
# Operate a Hydra node

docs/docs/how-to/sideload-snapshot.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22

3-
sidebar_position: 7
3+
sidebar_position: 8
44
---
55

66
# Sideload Snapshot

docs/docs/how-to/submit-transaction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 2
2+
sidebar_position: 3
33
---
44

55
# Submit a transaction

docs/docs/how-to/withdraw-zero.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 3
2+
sidebar_position: 4
33
---
44

55
# Use withdraw zero trick

0 commit comments

Comments
 (0)