Skip to content

Commit 9da291b

Browse files
committed
Fix commands
1 parent 85f7d15 commit 9da291b

File tree

1 file changed

+22
-27
lines changed

1 file changed

+22
-27
lines changed

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

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,15 @@ In this transaction, we will spend the script UTxO and send the funds to our own
131131
cardano-cli conway transaction build-raw \
132132
--tx-in <SCRIPT_UTXO_TXIX> \
133133
--tx-in-script-file always-true.plutus \
134-
--tx-in-datum-value 42 \
134+
--tx-in-inline-datum-present \
135135
--tx-in-redeemer-value 42 \
136136
--tx-in-execution-units '(0, 0)' \
137137
--tx-out $(cardano-cli address build --payment-verification-key-file hydra-cluster/config/credentials/alice-funds.vk --testnet-magic 1)+10000000 \
138138
--fee 0 \
139139
--out-file tx.json
140140
```
141141

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)`.
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 use `--tx-in-inline-datum-present` because the datum was already included on-chain when we created the script UTxO. 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)`.
143143

144144
## Step 5: Commit the script UTxO
145145

@@ -151,41 +151,36 @@ Once the Head is in the `Initializing` state, you can send the HTTP request to t
151151

152152
Just like in the other tutorial, you need to assemble a JSON request body. The `blueprintTx` is the `tx.json` file we just created, and the `utxo` is the script UTxO you are committing.
153153

154-
```json
155-
{
156-
"blueprintTx": {
157-
"type": "Tx BabbageEra",
158-
"description": "",
159-
"cborHex": "84a40081825820a5a11c227e92622321b7d526e0b7ade44c084f706e931e80829037cba55365f5000181825839000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f021a000f42400300a0f5f6"
160-
},
161-
"utxo": {
162-
"<SCRIPT_UTXO_TXIX>": {
163-
"address": "<SCRIPT_ADDRESS>",
164-
"datum": "42",
165-
"datumhash": null,
166-
"inlineDatum": true,
167-
"referenceScript": null,
168-
"value": {
169-
"lovelace": 10000000
170-
}
171-
}
172-
}
173-
}
154+
You can use the following script to query the necessary information and generate the `commit-request.json` file automatically. Make sure to replace `<SCRIPT_UTXO_TXIX>` with the actual transaction input of your script UTxO.
155+
156+
```shell
157+
# Set variables
158+
SCRIPT_UTXO_TXIX="<SCRIPT_UTXO_TXIX>"
159+
BLUEPRINT_JSON=$(cat tx.json)
160+
UTXO_JSON=$(cardano-cli query utxo --tx-in ${SCRIPT_UTXO_TXIX} --testnet-magic 1 --output-json)
161+
162+
# Create the request body
163+
jq -n \
164+
--argjson utxo "${UTXO_JSON}" \
165+
--argjson blueprintTx "${BLUEPRINT_JSON}" \
166+
'{ "utxo": $utxo, "blueprintTx": $blueprintTx }' \
167+
> commit-request.json
174168
```
175169

176-
Save this to a `commit-request.json` file and use `curl` to send it to the `hydra-node`:
170+
Now, use `curl` to send the request to the `hydra-node`, which will respond with a drafted commit transaction:
177171

178172
```shell
179-
curl -X POST 127.0.0.1:4001/commit \
180-
--data @commit-request.json
173+
curl -X POST --data @commit-request.json http://127.0.0.1:4001/commit > commit-tx.json
181174
```
182175

183-
This will give you the commit transaction, which you can then sign and submit as usual:
176+
This will give you the commit transaction, which you can then sign and submit as usual.
177+
The commit transaction must be signed by two keys: the key for the funds you are committing, and the party key that is participating in the Head.
184178

185179
```shell
186180
cardano-cli conway transaction sign \
187-
--tx-file commit-tx.json \
181+
--tx-body-file commit-tx.json \
188182
--signing-key-file hydra-cluster/config/credentials/alice-funds.sk \
183+
--signing-key-file hydra-cluster/config/credentials/alice.sk \
189184
--out-file signed-tx.json
190185

191186
cardano-cli conway transaction submit \

0 commit comments

Comments
 (0)