marlowe_lang 0.3.0

experimental parser lib for Cardano Marlowe DSL
Documentation
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Marlowe Lang\n",
    "\n",
    "\n",
    "Some basic usage-example for marlowe_lang.\n",
    "There is also an interactive example published at [runkit.com](https://runkit.com/olofblomqvist/marlowe-dsl-example)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "marlowe_lang utils initialized.\n"
     ]
    }
   ],
   "source": [
    "// depending on your env, you might want to use import * as m from 'marlowe_lang' (optionally using web/nodejs tags)\n",
    "let m = require('marlowe_lang')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Working with JSON"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\n",
      "  \"when\": [],\n",
      "  \"timeout_continuation\": \"close\",\n",
      "  \"timeout\": 123\n",
      "}\n"
     ]
    }
   ],
   "source": [
    "// Converting Marlowe DSL to JSON\n",
    "let json_encoded_contract = m.marlowe_to_json_with_variables('When [] (TimeParam \"var1\") Close',\"var1=123\") // or just marlowe_to_json if you dont need variables\n",
    "json_encoded_contract\n",
    "// if you just want to populate variables without converting to json, you can do:\n",
    "// m.parse_marlowe_with_variables(contract,\"Price=1\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "When [  ] 123 Close\n"
     ]
    }
   ],
   "source": [
    "m.decode_marlowe_dsl_from_json(json_encoded_contract)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Using the state machine"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Viewing current contract state\n",
    "**ie. next acceptable input actions**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\n",
      "  \"WaitingForInput\": {\n",
      "    \"expected\": [\n",
      "      {\n",
      "        \"Deposit\": {\n",
      "          \"who_is_expected_to_pay\": {\n",
      "            \"role_token\": \"Buyer\"\n",
      "          },\n",
      "          \"expected_asset_type\": {\n",
      "            \"token_name\": \"\",\n",
      "            \"currency_symbol\": \"\"\n",
      "          },\n",
      "          \"expected_amount\": 1000000,\n",
      "          \"expected_target_account\": {\n",
      "            \"role_token\": \"Seller\"\n",
      "          },\n",
      "          \"continuation\": \"close\"\n",
      "        }\n",
      "      }\n",
      "    ],\n",
      "    \"timeout\": 3487663680000\n",
      "  }\n",
      "}\n"
     ]
    }
   ],
   "source": [
    "let m = require('marlowe_lang')\n",
    "\n",
    "// Examine some contract state\n",
    "let contract = `When\n",
    "    [Case\n",
    "        (Deposit\n",
    "            (Role \"Seller\")\n",
    "            (Role \"Buyer\")\n",
    "            (Token \"\" \"\")\n",
    "            (ConstantParam \"Price\")\n",
    "        )\n",
    "        Close ]\n",
    "    3487663680000 Close \n",
    "`\n",
    "// Populate the variables\n",
    "let core_dsl = m.parse_marlowe_with_variables(contract,'Price=1000000');\n",
    "\n",
    "// Create state machine and process until it closes or requires input\n",
    "let machine = new m.WASMMarloweStateMachine(core_dsl,\"\");\n",
    "machine.process();\n",
    "\n",
    "// Read current state and print to console\n",
    "let current_state = machine.machine_state_json();\n",
    "current_state"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Parameters\n",
    "\n",
    "Marlowe has support for using variables, but those need to be set prior to initializing a contract so that it can run.\n",
    "You can inspect the parameters for a contract using \"get_input_params_for_contract\", and set them using \"parse_marlowe_with_variables\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The contract has the following variables [ 'CONST_PARAM:Price' ]\n",
      "After populating the 'Price' variable, the contract looks like this (marlowe core dsl) When [ (Case (Deposit (Role \"Seller\") (Role \"Buyer\") (Token \"\" \"\") (Constant 666)) Close) ] 3487663680000 Close\n"
     ]
    }
   ],
   "source": [
    "let param_list = m.get_input_params_for_contract(contract)\n",
    "let marlowe_core_dsl = m.parse_marlowe_with_variables(contract,\"Price=666\")\n",
    "\n",
    "console.log(\"The contract has the following variables\",param_list)\n",
    "console.log(\"After populating the 'Price' variable, the contract looks like this (marlowe core dsl)\",marlowe_core_dsl)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Working with CBORHEX"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "// Some example datum from here: https://preprod.cexplorer.io/tx/0b4fbb9e3ab2ada2249ab3b8b8f7520a833c224c19420f1fecef22601f9d6218\n",
    "let example_datum_cbor_hex = \"d8799fd8799f40ffd8799fa1d8799fd8799fd87980d8799fd8799f581c8b4e5029a73fd4155dfdcb5013e28db2fafb3e1ab487275f4aa50903ffd8799fd8799fd8799f581ccce6bfa02342d29adce20d09d3824463bfb59b0753d7d1d8514b376cffffffffffd8799f4040ffff1a001e8480a0a000ffd87c9f9fd8799fd8799fd8799fd87980d8799fd8799f581c8b4e5029a73fd4155dfdcb5013e28db2fafb3e1ab487275f4aa50903ffd8799fd8799fd8799f581ccce6bfa02342d29adce20d09d3824463bfb59b0753d7d1d8514b376cffffffffffd8799fd87980d8799fd8799f581c8b4e5029a73fd4155dfdcb5013e28db2fafb3e1ab487275f4aa50903ffd8799fd8799fd8799f581ccce6bfa02342d29adce20d09d3824463bfb59b0753d7d1d8514b376cffffffffffd8799f581c9772ff715b691c0444f333ba1db93b055c0864bec48fff92d1f2a7fe51446a65645f746573744d6963726f555344ffd87a9f1a3b9aca00ffffd87a9fd8799fd87980d8799fd8799f581c8b4e5029a73fd4155dfdcb5013e28db2fafb3e1ab487275f4aa50903ffd8799fd8799fd8799f581ccce6bfa02342d29adce20d09d3824463bfb59b0753d7d1d8514b376cffffffffffd87a9fd8799fd87980d8799fd8799f581c8b4e5029a73fd4155dfdcb5013e28db2fafb3e1ab487275f4aa50903ffd8799fd8799fd8799f581ccce6bfa02342d29adce20d09d3824463bfb59b0753d7d1d8514b376cffffffffffffd8799f581c9772ff715b691c0444f333ba1db93b055c0864bec48fff92d1f2a7fe51446a65645f746573744d6963726f555344ffd87a9f1a3b9aca00ffd87c9f9fd8799fd8799fd8799fd87980d8799fd8799f581c8b4e5029a73fd4155dfdcb5013e28db2fafb3e1ab487275f4aa50903ffd8799fd8799fd8799f581ccce6bfa02342d29adce20d09d3824463bfb59b0753d7d1d8514b376cffffffffffd8799fd87980d8799fd8799f581c8b4e5029a73fd4155dfdcb5013e28db2fafb3e1ab487275f4aa50903ffd8799fd8799fd8799f581ccce6bfa02342d29adce20d09d3824463bfb59b0753d7d1d8514b376cffffffffffd8799f581c9772ff715b691c0444f333ba1db93b055c0864bec48fff92d1f2a7fe51446a65645f746573744d6963726f555344ffd87f9fd87e9fd87a9f1a000186a0ffd87a9f1a3b9aca00ffffd87a9f1a000f4240ffffffd87a9fd8799fd87980d8799fd8799f581c8b4e5029a73fd4155dfdcb5013e28db2fafb3e1ab487275f4aa50903ffd8799fd8799fd8799f581ccce6bfa02342d29adce20d09d3824463bfb59b0753d7d1d8514b376cffffffffffd87a9fd8799fd87980d8799fd8799f581c8b4e5029a73fd4155dfdcb5013e28db2fafb3e1ab487275f4aa50903ffd8799fd8799fd8799f581ccce6bfa02342d29adce20d09d3824463bfb59b0753d7d1d8514b376cffffffffffffd8799f581c9772ff715b691c0444f333ba1db93b055c0864bec48fff92d1f2a7fe51446a65645f746573744d6963726f555344ffd87f9fd87e9fd87a9f1a000186a0ffd87a9f1a3b9aca00ffffd87a9f1a000f4240ffffd87c9f9fd8799fd8799fd8799fd87980d8799fd8799f581c8b4e5029a73fd4155dfdcb5013e28db2fafb3e1ab487275f4aa50903ffd8799fd8799fd8799f581ccce6bfa02342d29adce20d09d3824463bfb59b0753d7d1d8514b376cffffffffffd8799fd87980d8799fd8799f581c8b4e5029a73fd4155dfdcb5013e28db2fafb3e1ab487275f4aa50903ffd8799fd8799fd8799f581ccce6bfa02342d29adce20d09d3824463bfb59b0753d7d1d8514b376cffffffffffd8799f581c9772ff715b691c0444f333ba1db93b055c0864bec48fff92d1f2a7fe51446a65645f746573744d6963726f555344ffd87a9f1a3b9aca00ffffd87a9fd8799fd87980d8799fd8799f581c8b4e5029a73fd4155dfdcb5013e28db2fafb3e1ab487275f4aa50903ffd8799fd8799fd8799f581ccce6bfa02342d29adce20d09d3824463bfb59b0753d7d1d8514b376cffffffffffd87a9fd8799fd87980d8799fd8799f581c8b4e5029a73fd4155dfdcb5013e28db2fafb3e1ab487275f4aa50903ffd8799fd8799fd8799f581ccce6bfa02342d29adce20d09d3824463bfb59b0753d7d1d8514b376cffffffffffffd8799f581c9772ff715b691c0444f333ba1db93b055c0864bec48fff92d1f2a7fe51446a65645f746573744d6963726f555344ffd87a9f1a3b9aca00ffd87980ffffff1b000001941f297c00d87980ffffffff1b000001941f297c00d87980ffffffff1b0000018cc251f400d87980ffff\"\n",
    "\n",
    "// example from here: https://cardanoscan.io/transaction/f3a397d2f58f2c30a8034235659c5688b0c5d308581dbd7ce4470049b4aebd66?tab=contracts\n",
    "let example_redeemer_cbor_hex = \"9fd8799fd8799fd8799fd87a80d8799fd8799f581c1fdc22c9b2339e644d229335129b35e65161839660636675b29aa5a8ffd8799fd8799fd8799f581c43b85595ee70ca74e98583872933bec6c67a99982ca2f25547a89b4dffffffffffd8799fd87a80d8799fd8799f581c1fdc22c9b2339e644d229335129b35e65161839660636675b29aa5a8ffd8799fd8799fd8799f581c43b85595ee70ca74e98583872933bec6c67a99982ca2f25547a89b4dffffffffffd8799f581c85556ab05acc925edff2af02ef819a8b4903bfb5d5e100a7c95ab9084d4d61726c6f77654c6973626f6eff01ffffff\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### Decoding datums"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\n",
      "  \"marlowe_params\": \"\",\n",
      "  \"state\": {\n",
      "    \"accounts\": [\n",
      "      [\n",
      "        [\n",
      "          {\n",
      "            \"address\": \"addr_test1qz95u5pf5ulag92alh94qylz3ke047e7r26gwf6lf2jsjq7vu6l6qg6z62ddecsdp8fcy3rrh76ekp6n6lgas52txakq3eft7r\"\n",
      "          },\n",
      "          {\n",
      "            \"token_name\": \"\",\n",
      "            \"currency_symbol\": \"\"\n",
      "          }\n",
      "        ],\n",
      "        2000000\n",
      "      ]\n",
      "    ],\n",
      "    \"choices\": [],\n",
      "    \"boundValues\": [],\n",
      "    \"minTime\": 0\n",
      "  },\n",
      "  \"contract\": {\n",
      "    \"when\": [\n",
      "      {\n",
      "        \"then\": {\n",
      "          \"token\": {\n",
      "            \"token_name\": \"Djed_testMicroUSD\",\n",
      "            \"currency_symbol\": \"9772ff715b691c0444f333ba1db93b055c0864bec48fff92d1f2a7fe\"\n",
      "          },\n",
      "          \"to\": {\n",
      "            \"party\": {\n",
      "              \"address\": \"addr_test1qz95u5pf5ulag92alh94qylz3ke047e7r26gwf6lf2jsjq7vu6l6qg6z62ddecsdp8fcy3rrh76ekp6n6lgas52txakq3eft7r\"\n",
      "            }\n",
      "          },\n",
      "          \"then\": {\n",
      "            \"when\": [\n",
      "              {\n",
      "                \"then\": {\n",
      "                  \"token\": {\n",
      "                    \"token_name\": \"Djed_testMicroUSD\",\n",
      "                    \"currency_symbol\": \"9772ff715b691c0444f333ba1db93b055c0864bec48fff92d1f2a7fe\"\n",
      "                  },\n",
      "                  \"to\": {\n",
      "                    \"party\": {\n",
      "                      \"address\": \"addr_test1qz95u5pf5ulag92alh94qylz3ke047e7r26gwf6lf2jsjq7vu6l6qg6z62ddecsdp8fcy3rrh76ekp6n6lgas52txakq3eft7r\"\n",
      "                    }\n",
      "                  },\n",
      "                  \"then\": {\n",
      "                    \"when\": [\n",
      "                      {\n",
      "                        \"then\": {\n",
      "                          \"token\": {\n",
      "                            \"token_name\": \"Djed_testMicroUSD\",\n",
      "                            \"currency_symbol\": \"9772ff715b691c0444f333ba1db93b055c0864bec48fff92d1f2a7fe\"\n",
      "                          },\n",
      "                          \"to\": {\n",
      "                            \"party\": {\n",
      "                              \"address\": \"addr_test1qz95u5pf5ulag92alh94qylz3ke047e7r26gwf6lf2jsjq7vu6l6qg6z62ddecsdp8fcy3rrh76ekp6n6lgas52txakq3eft7r\"\n",
      "                            }\n",
      "                          },\n",
      "                          \"then\": \"close\",\n",
      "                          \"pay\": 1000000000,\n",
      "                          \"from_account\": {\n",
      "                            \"address\": \"addr_test1qz95u5pf5ulag92alh94qylz3ke047e7r26gwf6lf2jsjq7vu6l6qg6z62ddecsdp8fcy3rrh76ekp6n6lgas52txakq3eft7r\"\n",
      "                          }\n",
      "                        },\n",
      "                        \"case\": {\n",
      "                          \"party\": {\n",
      "                            \"address\": \"addr_test1qz95u5pf5ulag92alh94qylz3ke047e7r26gwf6lf2jsjq7vu6l6qg6z62ddecsdp8fcy3rrh76ekp6n6lgas52txakq3eft7r\"\n",
      "                          },\n",
      "                          \"of_token\": {\n",
      "                            \"token_name\": \"Djed_testMicroUSD\",\n",
      "                            \"currency_symbol\": \"9772ff715b691c0444f333ba1db93b055c0864bec48fff92d1f2a7fe\"\n",
      "                          },\n",
      "                          \"into_account\": {\n",
      "                            \"address\": \"addr_test1qz95u5pf5ulag92alh94qylz3ke047e7r26gwf6lf2jsjq7vu6l6qg6z62ddecsdp8fcy3rrh76ekp6n6lgas52txakq3eft7r\"\n",
      "                          },\n",
      "                          \"deposits\": 1000000000\n",
      "                        }\n",
      "                      }\n",
      "                    ],\n",
      "                    \"timeout_continuation\": \"close\",\n",
      "                    \"timeout\": 1735689600000\n",
      "                  },\n",
      "                  \"pay\": {\n",
      "                    \"divide\": {\n",
      "                      \"times\": 1000000000,\n",
      "                      \"multiply\": 100000\n",
      "                    },\n",
      "                    \"by\": 1000000\n",
      "                  },\n",
      "                  \"from_account\": {\n",
      "                    \"address\": \"addr_test1qz95u5pf5ulag92alh94qylz3ke047e7r26gwf6lf2jsjq7vu6l6qg6z62ddecsdp8fcy3rrh76ekp6n6lgas52txakq3eft7r\"\n",
      "                  }\n",
      "                },\n",
      "                \"case\": {\n",
      "                  \"party\": {\n",
      "                    \"address\": \"addr_test1qz95u5pf5ulag92alh94qylz3ke047e7r26gwf6lf2jsjq7vu6l6qg6z62ddecsdp8fcy3rrh76ekp6n6lgas52txakq3eft7r\"\n",
      "                  },\n",
      "                  \"of_token\": {\n",
      "                    \"token_name\": \"Djed_testMicroUSD\",\n",
      "                    \"currency_symbol\": \"9772ff715b691c0444f333ba1db93b055c0864bec48fff92d1f2a7fe\"\n",
      "                  },\n",
      "                  \"into_account\": {\n",
      "                    \"address\": \"addr_test1qz95u5pf5ulag92alh94qylz3ke047e7r26gwf6lf2jsjq7vu6l6qg6z62ddecsdp8fcy3rrh76ekp6n6lgas52txakq3eft7r\"\n",
      "                  },\n",
      "                  \"deposits\": {\n",
      "                    \"divide\": {\n",
      "                      \"times\": 1000000000,\n",
      "                      \"multiply\": 100000\n",
      "                    },\n",
      "                    \"by\": 1000000\n",
      "                  }\n",
      "                }\n",
      "              }\n",
      "            ],\n",
      "            \"timeout_continuation\": \"close\",\n",
      "            \"timeout\": 1735689600000\n",
      "          },\n",
      "          \"pay\": 1000000000,\n",
      "          \"from_account\": {\n",
      "            \"address\": \"addr_test1qz95u5pf5ulag92alh94qylz3ke047e7r26gwf6lf2jsjq7vu6l6qg6z62ddecsdp8fcy3rrh76ekp6n6lgas52txakq3eft7r\"\n",
      "          }\n",
      "        },\n",
      "        \"case\": {\n",
      "          \"party\": {\n",
      "            \"address\": \"addr_test1qz95u5pf5ulag92alh94qylz3ke047e7r26gwf6lf2jsjq7vu6l6qg6z62ddecsdp8fcy3rrh76ekp6n6lgas52txakq3eft7r\"\n",
      "          },\n",
      "          \"of_token\": {\n",
      "            \"token_name\": \"Djed_testMicroUSD\",\n",
      "            \"currency_symbol\": \"9772ff715b691c0444f333ba1db93b055c0864bec48fff92d1f2a7fe\"\n",
      "          },\n",
      "          \"into_account\": {\n",
      "            \"address\": \"addr_test1qz95u5pf5ulag92alh94qylz3ke047e7r26gwf6lf2jsjq7vu6l6qg6z62ddecsdp8fcy3rrh76ekp6n6lgas52txakq3eft7r\"\n",
      "          },\n",
      "          \"deposits\": 1000000000\n",
      "        }\n",
      "      }\n",
      "    ],\n",
      "    \"timeout_continuation\": \"close\",\n",
      "    \"timeout\": 1704067200000\n",
      "  }\n",
      "}\n"
     ]
    }
   ],
   "source": [
    "m.decode_cborhex_marlowe_plutus_datum(example_datum_cbor_hex)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Decoding redeemer/inputs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\n",
      "  \"Ok\": [\n",
      "    {\n",
      "      \"input_from_party\": {\n",
      "        \"address\": \"addr1qy0acgkfkgeeuezdy2fn2y5mxhn9zcvrjesxxen4k2d2t2zrhp2etmnsef6wnpvrsu5n80kxceafnxpv5te923agndxshwgt4u\"\n",
      "      },\n",
      "      \"of_tokens\": {\n",
      "        \"token_name\": \"MarloweLisbon\",\n",
      "        \"currency_symbol\": \"85556ab05acc925edff2af02ef819a8b4903bfb5d5e100a7c95ab908\"\n",
      "      },\n",
      "      \"into_account\": {\n",
      "        \"address\": \"addr1qy0acgkfkgeeuezdy2fn2y5mxhn9zcvrjesxxen4k2d2t2zrhp2etmnsef6wnpvrsu5n80kxceafnxpv5te923agndxshwgt4u\"\n",
      "      },\n",
      "      \"that_deposits\": 1\n",
      "    }\n",
      "  ]\n",
      "}\n"
     ]
    }
   ],
   "source": [
    "\n",
    "m.decode_marlowe_input_cbor_hex(example_redeemer_cbor_hex)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Try-decode\n",
    "\n",
    "If you don't know if the cbor-hex is a valid redeemer or datum, you can use the \"decode_marlowe_data_or_redeemer\" method\n",
    "which will attempt to figure out the correct way to decode it"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Decoded redeemer from cbor hex:\n",
      "\n",
      " (Deposit (Address \"addr1qy0acgkfkgeeuezdy2fn2y5mxhn9zcvrjesxxen4k2d2t2zrhp2etmnsef6wnpvrsu5n80kxceafnxpv5te923agndxshwgt4u\") (Address \"addr1qy0acgkfkgeeuezdy2fn2y5mxhn9zcvrjesxxen4k2d2t2zrhp2etmnsef6wnpvrsu5n80kxceafnxpv5te923agndxshwgt4u\") (Token \"85556ab05acc925edff2af02ef819a8b4903bfb5d5e100a7c95ab908\" \"MarloweLisbon\") 1)\n"
     ]
    }
   ],
   "source": [
    "\n",
    "m.decode_marlowe_data_or_redeemer(example_redeemer_cbor_hex)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Encoding contracts to cbor-hex\n",
    "\n",
    "Todo: This is currently not exposed in the WASM builds but only using the Rust crate.\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "TypeScript",
   "language": "typescript",
   "name": "tslab"
  },
  "language_info": {
   "codemirror_mode": {
    "mode": "typescript",
    "name": "javascript",
    "typescript": true
   },
   "file_extension": ".ts",
   "mimetype": "text/typescript",
   "name": "typescript",
   "version": "3.7.2"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}