You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
4006: Update example-reference-script-usage.sh to also use inline datums r=Jimbo4350 a=Jimbo4350
We introduce `--reference-tx-in-inline-datum-present` and `--tx-in-inline-datum-present` to indicate when we are using an inline datum.
Co-authored-by: Jordan Millar <[email protected]>
Copy file name to clipboardExpand all lines: doc/reference/plutus/babbage-script-example.md
+17-11
Original file line number
Diff line number
Diff line change
@@ -4,20 +4,26 @@
4
4
5
5
A reference script is a script that exists at a particular transaction output. It can be used to witness, for example, a UTxO at the corresponding script address of said reference script. This is useful because the script does not have to be included in the transaction anymore, which significantly reduces the transaction size.
6
6
7
+
## What is an inline datum?
8
+
9
+
An inline datum, is a datum that exists at a transaction output. We no longer have to include a datum within our transaction for our plutus spending scripts. Instead we can specify the transaction output where our datum exists to be used in conjunction with our Plutus spending script. This reduces the overall size of our transaction.
10
+
7
11
### An example of using a Plutus V2 reference script
8
12
9
-
Below is an example that shows how to use a Plutus spending script. Here we discuss a [shell script example of how to use a reference script to spend a tx input](scripts/plutus/example-reference-script-usage.sh). This is a step-by-step process involving:
13
+
Below is an example that shows how to use a Plutus spending script and an inline datum. Here we discuss a [shell script example of how to use a reference script to spend a tx input](scripts/plutus/example-babbage-script-usage.sh). This is a step-by-step process involving:
10
14
11
15
+ the creation of the `Required Redeemer` Plutus txin script
12
16
+ the creation of the `Required Redeemer` Plutus script at a transaction output (creation of the reference script)
13
-
+ sending ada and a datum to the Plutus script address
17
+
+ the creation of the inline datum at a transaction output
18
+
+ sending ada to the Plutus script address
14
19
+ spending ada at the Plutus script address using the Plutus reference script
15
20
16
21
In this example we will use the [Required Redeemer](scripts/plutus/scripts/v2/required-redeemer.plutus) Plutus spending script. In order to execute a reference Plutus spending script, we require the following:
17
22
18
23
- Collateral tx input(s) - these are provided and are forfeited in the event the Plutus script fails to execute.
19
-
- A Plutus tx output with accompanying datum hash. This is the tx output that sits at the Plutus script address. It must have a datum hash, otherwise, it is unspendable.
24
+
- A Plutus tx output. This is the tx output that sits at the Plutus script address.
20
25
- The reference transaction input containing the corresponding Plutus script. We must create the transaction output containing the reference Plutus script.
26
+
- An inline datum at the Plutus tx output. The Plutus spending script requires an inline datum or datum hash and in this case we are using an inline datum.
21
27
22
28
#### Creating the `Required Redeemer` Plutus spending script
23
29
@@ -48,10 +54,10 @@ cabal install cardano-node
48
54
```
49
55
50
56
To start your babbage cluster, you need to run the `example/run/all.sh` shell script.
51
-
The remainder of this guide provides a brief walkthrough of the [shell script example](scripts/plutus/example-reference-script-usage.sh) that automatically creates a reference script and spends the utxo at
57
+
The remainder of this guide provides a brief walkthrough of the [shell script example](scripts/plutus/example-babbage-script-usage.sh) that automatically creates a reference script and spends the utxo at
52
58
the reference script's corresponding script address.
53
59
54
-
#### Creating a reference script at a transaction output and
60
+
#### Creating a reference script at a transaction output, inline datum and
55
61
#### sending ada to the script address (with a datum)
56
62
57
63
In order to use a reference script, we must first create this script at a particular transaction output.
The following should be noted about this build command:
76
82
77
-
Firstly, we are sending ada to the plutus script address along with a datum hash. This is reflected in the following lines:
83
+
Firstly, we are sending ada and an inline datum to the plutus script address. This is reflected in the following lines:
78
84
79
85
```bash
80
86
...
81
87
--tx-out "$plutusscriptaddr+$lovelace" \
82
-
--tx-out-datum-hash"$scriptdatumhash" \
88
+
--tx-out-inline-datum-file"$datumfilepath" \
83
89
...
84
90
```
85
91
@@ -115,7 +121,7 @@ Because we are using the `build` command, we should only note the following:
115
121
`$plutusutxotxin` - This is the tx input that sits at the Plutus script address (NB: It has a datum hash).
116
122
`tx-in-reference` - This specifies the reference input you are using to witness a transaction input.
117
123
`plutus-script-v2`- This specifies the version of the reference script at the reference input.
118
-
`reference-tx-in-datum-file` - This is the datum to be used with the reference script.
124
+
`reference-tx-in-inline-datum-present` - This indicates that we are using an inline datum which exists at the utxo we are trying to spend (the utxo at the Plutus script address).
119
125
`reference-tx-in-redeemer-file` - This is the redeemer to be used with the reference script.
If there is ada at `$dummyaddress2`, then the Plutus script was successfully executed. Conversely, if the Plutus script failed, the collateral input would have been consumed.
151
+
If there is ada at `$dummyaddress2`, then the Plutus script was successfully executed.
146
152
147
153
You can use the [example-txin-locking-plutus-script.sh](../../../scripts/plutus/example-txin-locking-plutus-script.sh) in conjunction with [mkfiles.sh alonzo](../../../scripts/byron-to-alonzo/mkfiles.sh) script to automagically run the `AlwaysSucceeds` script.
0 commit comments