This repository has been archived by the owner on Nov 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path02-read.sh
executable file
·256 lines (200 loc) · 7.2 KB
/
02-read.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
#!/usr/bin/env bash
. env.sh
echo
### Altering data.
cardano-cli transaction build $MAGIC --alonzo-era \
--protocol-params-file $PROTOCOL \
--tx-in $TXID_2#1 \
--tx-in-script-file $SCRIPT_O \
--tx-in-datum-value "$(cat $DATUM_0)" \
--tx-in-redeemer-file ../redeemer-read.json \
--tx-in $TXID_1#4 \
--tx-in $TXID_2#0 \
--tx-out "$ADDRESS_S+5000000+1 $TOKEN_D+10 $TOKEN_F" \
--tx-out-datum-hash $HASH_1 \
--tx-out "$ADDRESS_1+5000000+990 $TOKEN_F" \
--change-address $ADDRESS_1 \
--tx-in-collateral $TXID_2#3 \
--out-file tx.raw 2>/dev/null
assert_failure "02a No reading if altering datum."
### Discarding data.
cardano-cli transaction build $MAGIC --alonzo-era \
--protocol-params-file $PROTOCOL \
--tx-in $TXID_2#1 \
--tx-in-script-file $SCRIPT_O \
--tx-in-datum-value "$(cat $DATUM_0)" \
--tx-in-redeemer-file ../redeemer-read.json \
--tx-in $TXID_1#4 \
--tx-in $TXID_2#0 \
--tx-out "$ADDRESS_S+5000000+1 $TOKEN_D+10 $TOKEN_F" \
--tx-out "$ADDRESS_1+5000000+990 $TOKEN_F" \
--change-address $ADDRESS_1 \
--tx-in-collateral $TXID_2#3 \
--out-file tx.raw 2>/dev/null
assert_failure "02b No reading if discarding datum."
### Stealing datum token.
cardano-cli transaction build $MAGIC --alonzo-era \
--protocol-params-file $PROTOCOL \
--tx-in $TXID_2#1 \
--tx-in-script-file $SCRIPT_O \
--tx-in-datum-value "$(cat $DATUM_0)" \
--tx-in-redeemer-file ../redeemer-read.json \
--tx-in $TXID_1#4 \
--tx-in $TXID_2#0 \
--tx-out "$ADDRESS_S+5000000+10 $TOKEN_F" \
--tx-out "$ADDRESS_1+5000000+1 $TOKEN_D+990 $TOKEN_F" \
--change-address $ADDRESS_1 \
--tx-in-collateral $TXID_2#3 \
--out-file tx.raw 2>/dev/null
assert_failure "02c No reading if stealing datum token."
### Stealing everything.
cardano-cli transaction build $MAGIC --alonzo-era \
--protocol-params-file $PROTOCOL \
--tx-in $TXID_2#1 \
--tx-in-script-file $SCRIPT_O \
--tx-in-datum-value "$(cat $DATUM_0)" \
--tx-in-redeemer-file ../redeemer-read.json \
--tx-in $TXID_1#4 \
--tx-in $TXID_2#0 \
--tx-out "$ADDRESS_1+5000000+1 $TOKEN_D+1000 $TOKEN_F" \
--change-address $ADDRESS_1 \
--tx-in-collateral $TXID_2#3 \
--out-file tx.raw 2>/dev/null
assert_failure "02d No reading if stealing everything."
### No fee.
cardano-cli transaction build $MAGIC --alonzo-era \
--protocol-params-file $PROTOCOL \
--tx-in $TXID_2#1 \
--tx-in-script-file $SCRIPT_O \
--tx-in-datum-value "$(cat $DATUM_0)" \
--tx-in-redeemer-file ../redeemer-read.json \
--tx-in $TXID_1#4 \
--tx-in $TXID_2#0 \
--tx-out "$ADDRESS_S+5000000+1 $TOKEN_D" \
--tx-out-datum-hash $HASH_0 \
--tx-out "$ADDRESS_1+5000000+100 $TOKEN_F" \
--change-address $ADDRESS_1 \
--tx-in-collateral $TXID_2#3 \
--out-file tx.raw 2>/dev/null
assert_failure "02e No reading without any fee."
### Insufficient fee.
cardano-cli transaction build $MAGIC --alonzo-era \
--protocol-params-file $PROTOCOL \
--tx-in $TXID_2#1 \
--tx-in-script-file $SCRIPT_O \
--tx-in-datum-value "$(cat $DATUM_0)" \
--tx-in-redeemer-file ../redeemer-read.json \
--tx-in $TXID_1#4 \
--tx-in $TXID_2#0 \
--tx-out "$ADDRESS_S+5000000+1 $TOKEN_D+9 $TOKEN_F" \
--tx-out-datum-hash $HASH_0 \
--tx-out "$ADDRESS_1+5000000+991 $TOKEN_F" \
--change-address $ADDRESS_1 \
--tx-in-collateral $TXID_2#3 \
--out-file tx.raw 2>/dev/null
assert_failure "02f No reading without sufficient fee."
### Excess fee.
cardano-cli transaction build $MAGIC --alonzo-era \
--protocol-params-file $PROTOCOL \
--tx-in $TXID_2#1 \
--tx-in-script-file $SCRIPT_O \
--tx-in-datum-value "$(cat $DATUM_0)" \
--tx-in-redeemer-file ../redeemer-read.json \
--tx-in $TXID_1#4 \
--tx-in $TXID_2#0 \
--tx-out "$ADDRESS_S+5000000+1 $TOKEN_D+11 $TOKEN_F" \
--tx-out-datum-hash $HASH_0 \
--tx-out "$ADDRESS_1+5000000+989 $TOKEN_F" \
--change-address $ADDRESS_1 \
--tx-in-collateral $TXID_2#3 \
--out-file tx.raw 2>/dev/null
assert_failure "02g No reading with excess fee."
### Insufficient ADA.
cardano-cli transaction build $MAGIC --alonzo-era \
--protocol-params-file $PROTOCOL \
--tx-in $TXID_2#1 \
--tx-in-script-file $SCRIPT_O \
--tx-in-datum-value "$(cat $DATUM_0)" \
--tx-in-redeemer-file ../redeemer-read.json \
--tx-in $TXID_1#4 \
--tx-in $TXID_2#0 \
--tx-out "$ADDRESS_S+4999999+1 $TOKEN_D+10 $TOKEN_F" \
--tx-out-datum-hash $HASH_0 \
--tx-out "$ADDRESS_1+5000000+990 $TOKEN_F" \
--change-address $ADDRESS_1 \
--tx-in-collateral $TXID_2#3 \
--out-file tx.raw 2>/dev/null
assert_failure "02h No reading without sufficient ADA."
### Excess ADA.
cardano-cli transaction build $MAGIC --alonzo-era \
--protocol-params-file $PROTOCOL \
--tx-in $TXID_2#1 \
--tx-in-script-file $SCRIPT_O \
--tx-in-datum-value "$(cat $DATUM_0)" \
--tx-in-redeemer-file ../redeemer-read.json \
--tx-in $TXID_1#4 \
--tx-in $TXID_2#0 \
--tx-out "$ADDRESS_S+5000001+1 $TOKEN_D+10 $TOKEN_F" \
--tx-out-datum-hash $HASH_0 \
--tx-out "$ADDRESS_1+5000000+990 $TOKEN_F" \
--change-address $ADDRESS_1 \
--tx-in-collateral $TXID_2#3 \
--out-file tx.raw 2>/dev/null
assert_failure "02i No reading with excess ADA."
### Insufficent fee, excess ADA.
cardano-cli transaction build $MAGIC --alonzo-era \
--protocol-params-file $PROTOCOL \
--tx-in $TXID_2#1 \
--tx-in-script-file $SCRIPT_O \
--tx-in-datum-value "$(cat $DATUM_0)" \
--tx-in-redeemer-file ../redeemer-read.json \
--tx-in $TXID_1#4 \
--tx-in $TXID_2#0 \
--tx-out "$ADDRESS_S+9999999+1 $TOKEN_D+9 $TOKEN_F" \
--tx-out-datum-hash $HASH_0 \
--tx-out "$ADDRESS_1+5000000+991 $TOKEN_F" \
--change-address $ADDRESS_1 \
--tx-in-collateral $TXID_2#3 \
--out-file tx.raw 2>/dev/null
assert_failure "02j No reading with insufficent fee and excess ADA."
### Insufficent ADA, excess fee.
cardano-cli transaction build $MAGIC --alonzo-era \
--protocol-params-file $PROTOCOL \
--tx-in $TXID_2#1 \
--tx-in-script-file $SCRIPT_O \
--tx-in-datum-value "$(cat $DATUM_0)" \
--tx-in-redeemer-file ../redeemer-read.json \
--tx-in $TXID_1#4 \
--tx-in $TXID_2#0 \
--tx-out "$ADDRESS_S+4999999+1 $TOKEN_D+99 $TOKEN_F" \
--tx-out-datum-hash $HASH_0 \
--tx-out "$ADDRESS_1+5000000+901 $TOKEN_F" \
--change-address $ADDRESS_1 \
--tx-in-collateral $TXID_2#3 \
--out-file tx.raw 2>/dev/null
assert_failure "02k No reading with insufficent ADA and excess fee."
### Reading.
cardano-cli transaction build $MAGIC --alonzo-era \
--protocol-params-file $PROTOCOL \
--tx-in $TXID_2#1 \
--tx-in-script-file $SCRIPT_O \
--tx-in-datum-value "$(cat $DATUM_0)" \
--tx-in-redeemer-file ../redeemer-read.json \
--tx-in $TXID_1#4 \
--tx-in $TXID_2#0 \
--tx-out "$ADDRESS_S+5000000+1 $TOKEN_D+10 $TOKEN_F" \
--tx-out-datum-hash $HASH_0 \
--tx-out "$ADDRESS_1+5000000+990 $TOKEN_F" \
--change-address $ADDRESS_1 \
--tx-in-collateral $TXID_2#3 \
--out-file tx.raw
assert_success "02l Reading."
cardano-cli transaction sign $MAGIC \
--tx-body-file tx.raw \
--out-file tx.signed \
--signing-key-file $PAYMENT_1
cardano-cli transaction submit $MAGIC \
--tx-file tx.signed
rm tx.{raw,signed}
### Record transaction.
echo "Run query.sh to find the resulting transaction and enter that as TXID_3 in local.sh."