Skip to content

Commit bdccbc1

Browse files
committed
Add a note about always-false
1 parent 8d4ca0c commit bdccbc1

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,37 @@ cardano-cli conway transaction submit \
211211
```
212212

213213
And that's it! After the transaction is confirmed on-chain, your script UTxO will be committed to the Head.
214+
215+
## Bonus: Experimenting with a Failing Script
216+
217+
It can be very insightful to see what happens when a script validator fails. To demonstrate this, you can create an "always false" validator and see how `cardano-cli`'s local validation prevents you from even building a transaction that uses it.
218+
219+
**1. Create the `always-false.plutus` script**
220+
221+
Create a new file named `always-false.plutus` with the following content. This is a valid Plutus script that is guaranteed to fail validation.
222+
223+
```json
224+
{
225+
"type": "PlutusScriptV2",
226+
"description": "Always false validator",
227+
"cborHex": "49480100002221200100"
228+
}
229+
```
230+
231+
**2. Lock funds with the failing script**
232+
233+
Follow the same steps as in **Step 3** and **Step 4** of the main tutorial, but use `always-false.plutus` instead of `always-true.plutus` to create a new script address and lock a new UTxO in it.
234+
235+
**3. Attempt to build a blueprint**
236+
237+
Now, try to run the `build-raw` command from **Step 5** using the UTxO locked by the failing script.
238+
239+
**Expected Result: Failure**
240+
241+
You will find that the `cardano-cli conway transaction build-raw` command itself will fail. It will produce an error message similar to this:
242+
243+
```shell
244+
Command failed: transaction build-raw Error: A script in the transaction has failed.
245+
```
246+
247+
This is a powerful feature of `cardano-cli`. It evaluates the scripts locally *before* creating the transaction. By catching the script failure at this early stage, it prevents you from submitting a transaction that would be guaranteed to fail on the blockchain, saving you time and the transaction fees.

0 commit comments

Comments
 (0)