Created
September 12, 2022 17:40
-
-
Save bwbush/5c6d2c634e66fb60e31c393195362035 to your computer and use it in GitHub Desktop.
Marlowe Reference Script Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"id": "13ae40be-3d3c-45a9-a766-f0380228e03d", | |
"metadata": {}, | |
"source": [ | |
"Record the versions of the tools used." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"id": "9fde1147-024e-4e26-8768-1e5399942e22", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"PATH=/extra/iohk/marlowe-cardano.PR227/dist-newstyle/build/x86_64-linux/ghc-8.10.7/marlowe-cli-0.0.7.0/x/marlowe-cli/build/marlowe-cli:$PATH" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"id": "b0383ad0-f776-4eb2-95ef-c0184a19e741", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"cardano-cli 1.35.3 - linux-x86_64 - ghc-8.10\n", | |
"git rev 0000000000000000000000000000000000000000\n" | |
] | |
} | |
], | |
"source": [ | |
"cardano-cli --version" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"id": "69434d67-95cd-4e88-90e1-d752cb9f7e87", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"marlowe-cli 0.0.7.0 @ a2ad214dd7930d9f57db768cdf1852ff938cf460\n" | |
] | |
} | |
], | |
"source": [ | |
"marlowe-cli --version" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "06697dda-a867-4bc5-b5c7-001d03256138", | |
"metadata": {}, | |
"source": [ | |
"## 1. Select the network\n", | |
"\n", | |
"We use the `preview` network. See [the configuration files](https://book.world.dev.cardano.org/environments.html#preview-testnet) and use [faucet](https://faucet.preview.world.dev.cardano.org/basic-faucet)." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"id": "ba5d0bc3-c852-4587-b0b8-48a5d65d7847", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"MAGIC=2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"id": "57e1813f-a614-4981-a016-aedb9684da47", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"export CARDANO_NODE_SOCKET_PATH=node.socket" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "120095ab-0c17-4aef-bd02-5a6e1e7a6e7d", | |
"metadata": {}, | |
"source": [ | |
"Find the current tip" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"id": "f5387df4-2cb8-480a-8fe6-b430cb85af02", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"The tip of the blockchain is at slot 2999979.\n" | |
] | |
} | |
], | |
"source": [ | |
"TIP=$(cardano-cli query tip --testnet-magic \"$MAGIC\" | jq .slot)\n", | |
"echo \"The tip of the blockchain is at slot $TIP.\"" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "135364c2-1a93-4806-8aca-c26691a4d2f7", | |
"metadata": {}, | |
"source": [ | |
"Retrieve the protocol parameters." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"id": "ab70c275-d534-40a0-b514-3d1993d5ec2a", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"cardano-cli query protocol-parameters --testnet-magic \"$MAGIC\" --out-file reference-script.protocol" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "38eb8467-8233-45ce-8a4a-23aadcfd6e2c", | |
"metadata": {}, | |
"source": [ | |
"We've empirically determined the slotting parameters for this network." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"id": "94039778-2768-4bb2-8402-87fdd8f22de5", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"SLOT_OFFSET=$((1660003200 * 1000)) # POSIX milliseconds for slot zero\n", | |
"SLOT_SPACING=1000 # milliseconds per slot" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"id": "6297879b-29c8-40d0-af85-425783a22b26", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"1660003200000\n" | |
] | |
} | |
], | |
"source": [ | |
"echo $SLOT_OFFSET" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "a941d9fa-8d96-4bc3-be45-cccfcf3af06f", | |
"metadata": {}, | |
"source": [ | |
"Convert a slot number to POSIX milliseconds." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 11, | |
"id": "f16e9a13-a5e0-4eed-9f65-d6c3af2cca0b", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"function slot2time () {\n", | |
" echo $(($1 * SLOT_SPACING + SLOT_OFFSET))\n", | |
"}" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "c9c76098-25da-420d-ae13-c567aaaa567c", | |
"metadata": {}, | |
"source": [ | |
"Convert POSIX milliseconds to a slot number." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 12, | |
"id": "82fba019-1cf4-43c8-baa8-9a0a1399ef0d", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"function time2slot () {\n", | |
" echo $((($1 - SLOT_OFFSET) / SLOT_SPACING))\n", | |
"}" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "caedded9-7e2d-4c90-993c-e47c92168b77", | |
"metadata": {}, | |
"source": [ | |
"Test the time conversion functions." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"id": "56cb6200-5f92-42e6-9e28-b1b1230e5326", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"1663003179000\n" | |
] | |
} | |
], | |
"source": [ | |
"NOW=$(slot2time $TIP)\n", | |
"echo $NOW" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 14, | |
"id": "e5a2f995-8a89-4b7a-940f-8a76dc5e1179", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Compare 2999979 to 2999979.\n" | |
] | |
} | |
], | |
"source": [ | |
"echo \"Compare $(time2slot $NOW) to $TIP.\"" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "27da618b-3c95-49a9-ad90-37398c03abda", | |
"metadata": {}, | |
"source": [ | |
"Define some time constants, for convenience." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 15, | |
"id": "6d0e7c40-273a-4e78-8197-aa10ed631f4a", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"SECOND=1000 # milliseconds per second\n", | |
"MINUTE=$((60 * SECOND)) # milliseconds per minute\n", | |
"HOUR=$((60 * MINUTE)) # milliseconds per hour\n", | |
"DAY=$((24 * HOUR)) # milliseconds per day" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "3a4c2015-62ec-4434-959c-cc4df3ef3ac6", | |
"metadata": {}, | |
"source": [ | |
"Define a constant for Ada." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 16, | |
"id": "f809c11f-5411-4d67-a781-16ef0cdbd162", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"ADA=1000000 # Lovelace per Ada" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "be518122-4b8b-4024-867a-0f0989aaf41d", | |
"metadata": {}, | |
"source": [ | |
"## 2. Select the signing and payment keys\n", | |
"\n", | |
"Use pre-existing stakeless keys for this example." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 19, | |
"id": "e34426b4-c24b-478e-b111-a6212b058764", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"PAYMENT_SKEY=/extra/iohk/networks/treasury/payment.skey\n", | |
"PAYMENT_VKEY=/extra/iohk/networks/treasury/payment.vkey" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "e613ac4e-a3a6-4023-9ef2-64461b20d310", | |
"metadata": {}, | |
"source": [ | |
"Compute the address." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 20, | |
"id": "cb55a5ca-a70c-41a7-80ae-9296e4f65cd9", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"addr_test1vq9prvx8ufwutkwxx9cmmuuajaqmjqwujqlp9d8pvg6gupczgtm9j\n" | |
] | |
} | |
], | |
"source": [ | |
"ADDRESS_P=$(cardano-cli address build --testnet-magic $MAGIC --payment-verification-key-file $PAYMENT_VKEY)\n", | |
"echo $ADDRESS_P" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "b68813f8-93e5-4be7-a729-1f105458f27b", | |
"metadata": {}, | |
"source": [ | |
"Compute the public key hash." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 21, | |
"id": "73a2ab58-de2b-4842-82d9-93eb9bf1f3c2", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"0a11b0c7e25dc5d9c63171bdf39d9741b901dc903e12b4e162348e07\n" | |
] | |
} | |
], | |
"source": [ | |
"PUBKEYHASH_P=$(cardano-cli address key-hash --payment-verification-key-file $PAYMENT_VKEY)\n", | |
"echo $PUBKEYHASH_P" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "cd85e76c-a335-4c32-a4d5-36ab4c1df93f", | |
"metadata": {}, | |
"source": [ | |
"Find a UTxO that we can use the fund the contract." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 22, | |
"id": "55626bf2-5740-46d4-8121-3d5aebfeb227", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
" TxHash TxIx Amount\n", | |
"--------------------------------------------------------------------------------------\n", | |
"601071672677ba341e94bc634d993bc2b5c85d43121d8735895a01456bb8130e 0 10000000000 lovelace + TxOutDatumNone\n", | |
"6b452603f7aecf73211c300d5fd1b55f8027114b52a3e6cda2e36efeef3029dc 0 79390443071 lovelace + TxOutDatumNone\n", | |
"6b452603f7aecf73211c300d5fd1b55f8027114b52a3e6cda2e36efeef3029dc 1 79340618605 lovelace + TxOutDatumNone\n", | |
"8909aeefb0cd4c4410e9e7566ef20db6888b23d26c0825f58c98a9d7445a01c1 0 533936067 lovelace + TxOutDatumNone\n", | |
"8f972918dd0be3f197abbbad98c82c4c033299291ac1dc434bdeaf679b8d7d75 0 164824769 lovelace + TxOutDatumNone\n", | |
"dbe16e67d5c294c589f74f90af34877095a731209386fc81fe493f64f6861474 0 10000000000 lovelace + TxOutDatumNone\n" | |
] | |
} | |
], | |
"source": [ | |
"cardano-cli query utxo --testnet-magic $MAGIC --address $ADDRESS_P" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 23, | |
"id": "717e7e15-b35c-44f4-83c5-018117d95f5b", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"TX_0=\"6b452603f7aecf73211c300d5fd1b55f8027114b52a3e6cda2e36efeef3029dc#0\"" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "ad2aa39f-2148-46ff-aa69-87e4585c7191", | |
"metadata": {}, | |
"source": [ | |
"## 3. Design the Marlowe contract\n", | |
"\n", | |
"For this demonstraction we just use a simple contract that involves two notifications and the refund of the Ada at the script address. Use the [Marlowe Playground](https://marlowe-playground-staging.plutus.aws.iohkdev.io/#/blockly) to create this contract and the \"Download JSON\" button to access the JSON representation of the contract.\n", | |
"\n", | |
"" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "9f230081-f390-472f-b3ac-51633b51323d", | |
"metadata": {}, | |
"source": [ | |
"We customize the downloaded JSON with our own timeout values." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 24, | |
"id": "f63ba44b-dec3-4797-a932-03f0e79ca7c4", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"1665595179000\n" | |
] | |
} | |
], | |
"source": [ | |
"TIMEOUT=$((NOW + 30 * DAY))\n", | |
"echo $TIMEOUT" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "a16ad307-5abe-40be-aab0-c94979584ecb", | |
"metadata": {}, | |
"source": [ | |
"### 3.1. Creation" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "1b442906-ed7b-4298-b1d3-c213aae6922d", | |
"metadata": {}, | |
"source": [ | |
"The initial contract has two notifications." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 25, | |
"id": "18d03550-a9d4-476d-a49a-0fe959bfa91e", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"timeout: 1665595179000\n", | |
"timeout_continuation: close\n", | |
"when:\n", | |
"- case:\n", | |
" notify_if: true\n", | |
" then:\n", | |
" timeout: 1665595179000\n", | |
" timeout_continuation: close\n", | |
" when:\n", | |
" - case:\n", | |
" notify_if: true\n", | |
" then: close\n" | |
] | |
} | |
], | |
"source": [ | |
"cat > reference-script-1.contract << EOI\n", | |
"{\n", | |
" \"when\" : [\n", | |
" {\n", | |
" \"case\" : { \"notify_if\" : true },\n", | |
" \"then\" : {\n", | |
" \"when\" : [\n", | |
" {\n", | |
" \"case\" : { \"notify_if\" : true },\n", | |
" \"then\" : \"close\"\n", | |
" }\n", | |
" ],\n", | |
" \"timeout\": $TIMEOUT,\n", | |
" \"timeout_continuation\" : \"close\"\n", | |
" }\n", | |
" }\n", | |
" ],\n", | |
" \"timeout\" : $TIMEOUT,\n", | |
" \"timeout_continuation\" : \"close\"\n", | |
"}\n", | |
"EOI\n", | |
"json2yaml reference-script-1.contract" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "861e6b77-4fea-4627-92cb-c61dea4b49b4", | |
"metadata": {}, | |
"source": [ | |
"We set the initial state to hold a small amount of Ada." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 26, | |
"id": "845a111f-e2e8-4f15-9bdd-1a2428d26e7b", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"ACCOUNT_LOVELACE=$((3 * ADA))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 27, | |
"id": "01a2d6de-e71a-408a-a238-91a3763d36f9", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"accounts:\n", | |
"- - - pk_hash: 0a11b0c7e25dc5d9c63171bdf39d9741b901dc903e12b4e162348e07\n", | |
" - currency_symbol: ''\n", | |
" token_name: ''\n", | |
" - 3000000\n", | |
"boundValues: []\n", | |
"choices: []\n", | |
"minTime: 1663003179000\n" | |
] | |
} | |
], | |
"source": [ | |
"cat << EOI > reference-script-1.state\n", | |
"{\n", | |
" \"accounts\" : [\n", | |
" [\n", | |
" [\n", | |
" { \"pk_hash\" : \"$PUBKEYHASH_P\" },\n", | |
" { \"currency_symbol\" : \"\", \"token_name\" : \"\" }\n", | |
" ],\n", | |
" $ACCOUNT_LOVELACE\n", | |
" ]\n", | |
" ],\n", | |
" \"choices\" : [],\n", | |
" \"boundValues\" : [],\n", | |
" \"minTime\" : $NOW\n", | |
"}\n", | |
"EOI\n", | |
"json2yaml reference-script-1.state" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "021e986d-a0dd-4ced-ab2b-0f3b98a330df", | |
"metadata": {}, | |
"source": [ | |
"### 3.2. First notification\n", | |
"\n", | |
"We send an `INotify` to the contract." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 28, | |
"id": "704e49cc-0eef-45c6-a87c-c374ebb6b3c6", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"input_notify\n", | |
"...\n" | |
] | |
} | |
], | |
"source": [ | |
"marlowe-cli input notify > reference-script-1.input\n", | |
"json2yaml reference-script-1.input" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "0b96ca03-adaa-44da-b47d-a9c5a841b66f", | |
"metadata": {}, | |
"source": [ | |
"The contract then becomes much simpler." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 29, | |
"id": "9d134a22-48ca-4614-96de-1f920156ee1d", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"timeout: 1665595179000\n", | |
"timeout_continuation: close\n", | |
"when:\n", | |
"- case:\n", | |
" notify_if: true\n", | |
" then: close\n" | |
] | |
} | |
], | |
"source": [ | |
"cat > reference-script-2.contract << EOI\n", | |
"{\n", | |
" \"when\" : [\n", | |
" {\n", | |
" \"case\" : { \"notify_if\" : true },\n", | |
" \"then\" : \"close\"\n", | |
" }\n", | |
" ],\n", | |
" \"timeout\" : $TIMEOUT,\n", | |
" \"timeout_continuation\" : \"close\"\n", | |
"}\n", | |
"EOI\n", | |
"json2yaml reference-script-2.contract" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "ec8808a6-365b-4324-b319-8fe39bdfb1a4", | |
"metadata": {}, | |
"source": [ | |
"We plan to submit the input within the following validity range." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 30, | |
"id": "94dcb267-6008-4419-b919-6d240f26993f", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"2999979 3017979\n" | |
] | |
} | |
], | |
"source": [ | |
"INVALID_BEFORE=$(time2slot $NOW)\n", | |
"INVALID_HEREAFTER=$(time2slot $((NOW + 5 * HOUR)))\n", | |
"echo \"$INVALID_BEFORE $INVALID_HEREAFTER\"" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "f88eadbc-df72-4231-b55c-823769e29edb", | |
"metadata": {}, | |
"source": [ | |
"This means that the state after the first input will be the same as the previous state, since no adjustment of `minTime` occurs due to this validity range." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 31, | |
"id": "32482236-24b5-42d0-afaf-01f296b94e38", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"accounts:\n", | |
"- - - pk_hash: 0a11b0c7e25dc5d9c63171bdf39d9741b901dc903e12b4e162348e07\n", | |
" - currency_symbol: ''\n", | |
" token_name: ''\n", | |
" - 3000000\n", | |
"boundValues: []\n", | |
"choices: []\n", | |
"minTime: 1663003179000\n" | |
] | |
} | |
], | |
"source": [ | |
"cat << EOI > reference-script-2.state\n", | |
"{\n", | |
" \"accounts\" : [\n", | |
" [\n", | |
" [\n", | |
" { \"pk_hash\" : \"$PUBKEYHASH_P\" },\n", | |
" { \"currency_symbol\" : \"\", \"token_name\" : \"\" }\n", | |
" ],\n", | |
" $ACCOUNT_LOVELACE\n", | |
" ]\n", | |
" ],\n", | |
" \"choices\" : [],\n", | |
" \"boundValues\" : [],\n", | |
" \"minTime\" : $NOW\n", | |
"}\n", | |
"EOI\n", | |
"json2yaml reference-script-2.state" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "6b4b340f-a073-453e-87da-f0749fecf917", | |
"metadata": { | |
"tags": [] | |
}, | |
"source": [ | |
"### 3.3. Second notification and closure\n", | |
"\n", | |
"We send another `INotify` to the contract, which causes it to close." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 32, | |
"id": "5178199e-9d70-4739-b7d6-ad7abb3fbb3c", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"input_notify\n", | |
"...\n" | |
] | |
} | |
], | |
"source": [ | |
"marlowe-cli input notify > reference-script-2.input\n", | |
"json2yaml reference-script-2.input" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "f227d39e-d885-4667-9ebe-4ca9d0d10236", | |
"metadata": {}, | |
"source": [ | |
"The contract just becomes `Close`." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 33, | |
"id": "11cb3278-a0bf-4268-b99b-65e4e44adc19", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"close\n", | |
"...\n" | |
] | |
} | |
], | |
"source": [ | |
"cat > reference-script-3.contract << EOI\n", | |
"\"close\"\n", | |
"EOI\n", | |
"json2yaml reference-script-3.contract" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "9918a92c-2206-43f6-a612-006fa22cb24a", | |
"metadata": {}, | |
"source": [ | |
"The state becomes empty." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 34, | |
"id": "22ac5352-e534-4158-b08a-4beb7e870b09", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"accounts: []\n", | |
"boundValues: []\n", | |
"choices: []\n", | |
"minTime: 1663003179000\n" | |
] | |
} | |
], | |
"source": [ | |
"cat << EOI > reference-script-3.state\n", | |
"{\n", | |
" \"accounts\" : [],\n", | |
" \"choices\" : [],\n", | |
" \"boundValues\" : [],\n", | |
" \"minTime\" : $NOW\n", | |
"}\n", | |
"EOI\n", | |
"json2yaml reference-script-3.state" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "0cef9780-cf87-43c2-a5e5-88a9773eff7f", | |
"metadata": {}, | |
"source": [ | |
"## 4. Run the transactions" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "57d145ca-05b2-491a-be9d-f8dc9a83f28f", | |
"metadata": {}, | |
"source": [ | |
"### 4.1. Creation\n", | |
"\n", | |
"Bundle the contract and state, computing the datum and script." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 35, | |
"id": "b4eec428-ee73-43b4-b40d-9f8c877053cf", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"\n", | |
"Bare-validator cost: ExBudget {exBudgetCPU = ExCPU 18515100, exBudgetMemory = ExMemory 80600}\n", | |
"Validator size: 12642\n", | |
"Datum size: 139\n", | |
"Redeemer size: 3\n", | |
"Total size: 12784\n" | |
] | |
} | |
], | |
"source": [ | |
"marlowe-cli contract marlowe --testnet-magic \"$MAGIC\" \\\n", | |
" --contract-file reference-script-1.contract \\\n", | |
" --state-file reference-script-1.state \\\n", | |
" --out-file reference-script-1.marlowe \\\n", | |
" --print-stats" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "2727b48e-389e-468f-88f3-1c8186f446c4", | |
"metadata": {}, | |
"source": [ | |
"Extract the Plutus script and its address." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 36, | |
"id": "6df35fc5-6a3c-46de-8e85-542e7f33d76b", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"{\n", | |
" \"cborHex\": \"59316259315f01000033232323322323232323232323232323232323233223232323232323232323232323322323232323232323232332233223232323232323322323232323232323232323232332233223232323232323232323232323232323232323232323232323232323232323232323232323322323232323232323232323232323232323232323223222232325335333222350032232322350062323232323223353235001223500223223355335333573466e2000400c22c04228044c0d0c8488c00400ccd542180400c00454cd4ccd5cd19b88001501008b0108a0113034332212233002004003501033550860100300113322122330010040033355086015002001350112222333308901004003002500623033122222300200622533335333333305308c01002001010006509d01509d01130341222220051303412222200313034122222004222221533500513333038004003002001153333335015221303b03c13501822225335333355307612001505e2209701004096011303d03e1333303c0080070060052221303c03d2221303c03d222221303e03f2221303c03d15335333573466e2400540382240422004540384004cc8848cc00400c008d4d401c88888888888801488d4008894ccd400884d4010894ccd400884cd54220040100044c1d926130" | |
] | |
} | |
], | |
"source": [ | |
"jq '.validator.script' reference-script-1.marlowe > reference-script.plutus\n", | |
"head -c 1000 reference-script.plutus" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 37, | |
"id": "83e36e06-a49a-4e9b-b56e-e35d7a9d0fb9", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"addr_test1wzvmq4tgspn7sdps4dhqf02ta28jetz8drcwpxlaytp0z2ga35plq\n" | |
] | |
} | |
], | |
"source": [ | |
"ADDRESS_S=$(jq -r '.validator.address' reference-script-1.marlowe)\n", | |
"echo $ADDRESS_S" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 38, | |
"id": "00d66b8f-3d51-4622-bd03-dd9235ebb882", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Estimated transaction fee: Lovelace 722453\n" | |
] | |
} | |
], | |
"source": [ | |
"cardano-cli transaction build --testnet-magic \"$MAGIC\" \\\n", | |
" --babbage-era \\\n", | |
" --protocol-params-file reference-script.protocol \\\n", | |
" --tx-in \"$TX_0\" \\\n", | |
" --tx-out \"$ADDRESS_P+$((60 * ADA))\" \\\n", | |
" --tx-out-reference-script-file reference-script.plutus \\\n", | |
" --change-address \"$ADDRESS_P\" \\\n", | |
" --out-file tx-1.raw" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 39, | |
"id": "88cc630a-7152-4b02-b73d-084215f95b11", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"cardano-cli transaction sign --testnet-magic \"$MAGIC\" \\\n", | |
" --tx-body-file tx-1.raw \\\n", | |
" --signing-key-file \"$PAYMENT_SKEY\" \\\n", | |
" --out-file tx-1.signed" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 40, | |
"id": "8874a0b4-00fe-4575-8407-8f1d0f21173d", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Transaction successfully submitted.\n" | |
] | |
} | |
], | |
"source": [ | |
"cardano-cli transaction submit --testnet-magic \"$MAGIC\" \\\n", | |
" --tx-file tx-1.signed" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 43, | |
"id": "abb14aae-880d-4c58-b32e-7b09134c5a95", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
" TxHash TxIx Amount\n", | |
"--------------------------------------------------------------------------------------\n", | |
"601071672677ba341e94bc634d993bc2b5c85d43121d8735895a01456bb8130e 0 10000000000 lovelace + TxOutDatumNone\n", | |
"6b452603f7aecf73211c300d5fd1b55f8027114b52a3e6cda2e36efeef3029dc 1 79340618605 lovelace + TxOutDatumNone\n", | |
"8909aeefb0cd4c4410e9e7566ef20db6888b23d26c0825f58c98a9d7445a01c1 0 533936067 lovelace + TxOutDatumNone\n", | |
"8f972918dd0be3f197abbbad98c82c4c033299291ac1dc434bdeaf679b8d7d75 0 164824769 lovelace + TxOutDatumNone\n", | |
"c02630ec7268939fa03028248f9287bb00c08ac44357d485df062f460b6734e8 0 79329720618 lovelace + TxOutDatumNone\n", | |
"c02630ec7268939fa03028248f9287bb00c08ac44357d485df062f460b6734e8 1 60000000 lovelace + TxOutDatumNone\n", | |
"dbe16e67d5c294c589f74f90af34877095a731209386fc81fe493f64f6861474 0 10000000000 lovelace + TxOutDatumNone\n" | |
] | |
} | |
], | |
"source": [ | |
"cardano-cli query utxo --testnet-magic $MAGIC --address $ADDRESS_P" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "51f38bec-cd2e-44fd-9dda-008a695131fe", | |
"metadata": {}, | |
"source": [ | |
"Record the transaction ID." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 44, | |
"id": "eb717560-49bd-438e-a72c-245cb18fb1fb", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"TX_1=c02630ec7268939fa03028248f9287bb00c08ac44357d485df062f460b6734e8" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "cc9182ef-94f8-41bf-9776-00135165832f", | |
"metadata": {}, | |
"source": [ | |
"Extract the datum." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 45, | |
"id": "1117eb26-7106-4859-865f-a59c2192178d", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"jq '.datum.json' reference-script-1.marlowe > reference-script-1.datum" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "89f3a698-2d30-417c-a4ae-448ee004413b", | |
"metadata": {}, | |
"source": [ | |
"Build the transaction" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 46, | |
"id": "a126d8da-30f9-44da-ba99-d336a79ed1af", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Estimated transaction fee: Lovelace 175005\n" | |
] | |
} | |
], | |
"source": [ | |
"cardano-cli transaction build --testnet-magic \"$MAGIC\" \\\n", | |
" --babbage-era \\\n", | |
" --protocol-params-file reference-script.protocol \\\n", | |
" --tx-in \"$TX_1#0\" \\\n", | |
" --tx-out \"$ADDRESS_S+$ACCOUNT_LOVELACE\" \\\n", | |
" --tx-out-datum-embed-file reference-script-1.datum \\\n", | |
" --change-address \"$ADDRESS_P\" \\\n", | |
" --out-file tx-2.raw" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 47, | |
"id": "0bf36fa8-ab0d-4a83-88dc-609477df69d4", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"cardano-cli transaction sign --testnet-magic \"$MAGIC\" \\\n", | |
" --tx-body-file tx-2.raw \\\n", | |
" --signing-key-file \"$PAYMENT_SKEY\" \\\n", | |
" --out-file tx-2.signed" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 48, | |
"id": "50066674-2088-437e-9555-c68d1e4aa717", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Transaction successfully submitted.\n" | |
] | |
} | |
], | |
"source": [ | |
"cardano-cli transaction submit --testnet-magic \"$MAGIC\" \\\n", | |
" --tx-file tx-2.signed" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "1bddb83f-cb4d-44ab-ac9d-8624fb05eefa", | |
"metadata": {}, | |
"source": [ | |
"Wait for the transaction to be confirmed. (One can check the node logs to see when the confirmation has occurred.)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 49, | |
"id": "0747c02c-0d3f-4934-bbe8-bda57be70ed8", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
" TxHash TxIx Amount\n", | |
"--------------------------------------------------------------------------------------\n", | |
"040814b28e6741bf8bcca03e9350626e0a2b6c56f180d0f3bdc1b7ed77fd43d2 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"81671bb1d4b81e0eb43263041b831b632eb16c11927b1c33b1c8fe03c8f4d9c3\"\n", | |
"06c30bd4e5b043584e80a67a61b7de3e789266b0fc9497fe0604235e63ad5160 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"132ffdcc65c82939a06ead32edda3d09655161b377f3ff512df1b5166597ca3e\"\n", | |
"09e8f95117ee9d0c773932fd3774148986beeff52c1e945752bee75cdb63a07a 1 25000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"957004e48fcabfa64716e45a8860afbe7ed363ae2110de15080d111436d7513b\"\n", | |
"2a6267fbe3c56ba72f3a06a52e991a74e1fd13f97f5c8ffe6887f6699230ad6b 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"d81828c3915542ae7a8a002993c38b9539ad397843afef82a351c9efd6b73902\"\n", | |
"2cf9a5f40cf8f18f841c2982cfb3eae8e372766d74293189338ba3788e34482e 1 25000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"3a2104612975fc5c9c2dd9f12172985e03d97cf8fd8a8142ed2ef28aa425a611\"\n", | |
"2f3ee57755eb7fed435f97d03906122dea73104e5b312fcc84e9747ca521861f 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"02bbdfac4d3b298b06a4ee907636fdb075b1a668295102a55d3d1df3112e02f3\"\n", | |
"305023f885ddcddcc919beda109226dd05ce4a56674e6bf21ad94a1d05489b74 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"a7cc909f7eefb07e23b61a2e106701f8f484120cf82cf1d1b1f886c41d070624\"\n", | |
"339daf8dac93eb1fcd4cc2c5319c0d6560bce72cdae5220c10a7f474c5c9f1b4 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"9fc2fd5b6dac9cf01b6f37c7f0beb6356d5a8750735623fc872cf32da828613b\"\n", | |
"3987bab0d1e1e12f7b6a66f69658e4b05e1b37104aebc44d01ffaf651f055190 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"ca903111ac28eb71f8deede53049045f57b8f7a43f6f2551083bdc2dcf903f43\"\n", | |
"3f0aaacf43b65c1e7a714d75eb1dc795cc5bfc918e8f775027d00c22cd9ff90d 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"662bd442551ff081481da1004ca26f561c42ca8238576b88ce977f57d9df7587\"\n", | |
"4903d88090972f231beecf0d993728baf8d4ab101e3ff43c97b9baf6c9c118fe 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"b3aeae799f4aee5d7410595c7476844798408ad5d756ec1295ecad74fb3e8828\"\n", | |
"565759233ab826ab3b17535f52244ef5a91ac8820b76193ad1dfa778f86a036e 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"a4533d7298ecc158f4f1921853cca0df90ee93225b9d31451254fc6a366b972f\"\n", | |
"592d44a3092994f4429606aeed6fcabc38344e5fcc7a1d383a46d37fddef10d9 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"befa82c806a7a26822b9713d06ae7e333a107e18df3fb1c7b73745b2f846c6ef\"\n", | |
"69073b20501d2c50e8019e5eccd716a46364b221b8c318cd4ebae6a52c0d1cbc 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"a757c6cb4cafa33e8578dfddf7b5c75931f8fb327180a3d15dac125a239914eb\"\n", | |
"6b5963bf6cb7207851a34d896776d371ef9a645107cf2780b02188dba73d39cf 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"689513c315308df35bc15c3bbfe2a15da7e0048c4412523f62cb0a4277a2b461\"\n", | |
"6dbf4846b98777e9a8348945ceaa673712b38ca65c07e142a6efae3ecf412954 1 3000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"666767be5cd45977b3246ef7a07a90925a1fe5c1beb0550e5310171be40c6661\"\n", | |
"7254e1a0bf50723f624576ca92ed1bd10d8bcaee7f40f723e71ff6515035c4a8 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"5c32953f3cb9e2f8b018a8f05b0b031962f2563363e2d2bde92709574e132617\"\n", | |
"76d1a24ee496dcfaa936b6f0d0103f525abdcc6efda6e1c7930c35990625f739 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"085e014d829aacbcb9d653e63a1dfeffaf1e49b7902c8e7f30a2e40136e27b65\"\n", | |
"948cf549e85061c9857b2649667eecee8414cc1bbc4a04e3c0ce1fb26bde0123 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"c6c96d1f12c68bac0c8d9ad3bf2643bd32509a5f5cf58a3f7524f82c822c5253\"\n", | |
"9b65472a550b5efa1ed4eeafc48fccb24b93852f6213ba15a5347ffe064f252f 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"f288178de30b7569c7ac13a687ad110c46fb6f965a7ac5d30dec5b6273db1fc9\"\n", | |
"a732afff25560cdb9d246810a29f070d39c6e28cc7c3c99de00af06f344f2183 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"c239e9811a0bf0a21356a1627201e597651537b7a13a05da161fc57daaee243c\"\n", | |
"acd8d2090a2075fcb493511e16e6a65a3b39f0d7ef9289f743fc923d9c03d6fe 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"8f153f30984a90d35a310529013ed6431bedf9f727c0404a2838d351d8812e04\"\n", | |
"b336de6edf70b537f8f9b67ac6c8c6360df5333b8ae5289cfe4ddcedfc7dece4 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"44a2053a41d627219383994f01affccf8a75ea4b4c9f369499d2dd864f9f5106\"\n", | |
"ba21f2ad50ed6af048114566eb577116303c099b512c55330387f2d76927ca0e 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"18caf27a5b8ef0856926b53e22bc71a80fb2b7e2c20e7484b4b72efaef7bbb7a\"\n", | |
"c47a0a633416eda2cd1e5f23857146691e31bf384732286959b0d7cdcdb5dd83 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"87fbf89da6c03879de9c4719d09acc7f20a192bb5cb704ed55aade4d65b6afe8\"\n", | |
"cb94a8869eec4ab7f40113f05f8a7a933118e2bbd140f8c1063123148004f734 1 25000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"395526da0e084e06ef5da074c119c34fe6720dd715e710e178122ffc5f93098d\"\n", | |
"d3074e879db9616d5a1fb6754f677f37a798a42dde3e173b18703c2a782988aa 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"268e7f8b2d2fcb95fb8fc5c6f08a944d5ac0d060048609cc85a3448c65b5e834\"\n", | |
"d3dbd9b9815dcfc550c8d6921cb4f84730b6f4abebc4b84274399406517cab24 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"1c1d63d52ecb6bcf7fef9854ba5a99579661198e5ecec6a0258926d85f7907a9\"\n", | |
"dadf5f352f6465c16cc851f9bfba0c07a4028e7f7116612f1c55fe5395fbe9e0 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"29f76491688b4262a8da0bb773cb133894851cb9aeb28add9efded1022e58cd2\"\n", | |
"de7e2c7d9e5806e46f9219aecbc2c979df8c95687fa0468a1d303d0c7c9a0c98 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"609c954f67e16322ea42224c23ddfeae843b22325c2e49ff306010398753cfc7\"\n", | |
"e87462f313b2c1ee339150a8c3f08cd6d3c33f7a6d398e6ad045ea8bab1694ff 1 25000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"d001bad4f5f472f52200be1f209487a4ecd7951ec9a0416dae7fbfe6b6915eae\"\n", | |
"e987e1eecaf62f4de13beeec628989f185536c32876130fd08f657c3b9920fa1 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"d24c24a2fcea50f54e3cd9993acde5667fe0467a221da982d553ed1b1ab592e6\"\n", | |
"f6e78eb0df3c1aeee814cc11654326ab1eda06cef267ed01d4ea30701c8cc331 1 25000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"55f8e2e8125a464b36422f2ce4c4ae48389a9cfffd0e51612a894cd05619595d\"\n", | |
"fdb1aa1dd35941eba955c1caa4c3b3935e443dc685012d89eb0ec3469b51e347 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"8010cd1479847668424f6cf148b1bd31e073bdd91980e7d17e93527bc0482b07\"\n", | |
"ff8b3fafbae455568b8181c2b291b26189a14e1d1fe47873c4ff8cb32602e567 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"61b27c02ee14f93a0da5ecdd9f363cc02f8ab192c01c1f0dd1169abccd4291af\"\n" | |
] | |
} | |
], | |
"source": [ | |
"cardano-cli query utxo --testnet-magic $MAGIC --address $ADDRESS_S" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "5cf2cd37-68c3-4ed4-8864-3a410c46f05a", | |
"metadata": {}, | |
"source": [ | |
"Record the transaction ID." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 50, | |
"id": "d60f8afb-9848-4c4d-8e03-e47674b650a9", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"TX_2=6dbf4846b98777e9a8348945ceaa673712b38ca65c07e142a6efae3ecf412954" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "c9aead22-d346-43c3-9571-bcd3996a710a", | |
"metadata": {}, | |
"source": [ | |
"See that the change has been received" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 51, | |
"id": "153f2874-af6d-4a48-a5d7-1433c1827409", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
" TxHash TxIx Amount\n", | |
"--------------------------------------------------------------------------------------\n", | |
"601071672677ba341e94bc634d993bc2b5c85d43121d8735895a01456bb8130e 0 10000000000 lovelace + TxOutDatumNone\n", | |
"6b452603f7aecf73211c300d5fd1b55f8027114b52a3e6cda2e36efeef3029dc 1 79340618605 lovelace + TxOutDatumNone\n", | |
"6dbf4846b98777e9a8348945ceaa673712b38ca65c07e142a6efae3ecf412954 0 79326545613 lovelace + TxOutDatumNone\n", | |
"8909aeefb0cd4c4410e9e7566ef20db6888b23d26c0825f58c98a9d7445a01c1 0 533936067 lovelace + TxOutDatumNone\n", | |
"8f972918dd0be3f197abbbad98c82c4c033299291ac1dc434bdeaf679b8d7d75 0 164824769 lovelace + TxOutDatumNone\n", | |
"c02630ec7268939fa03028248f9287bb00c08ac44357d485df062f460b6734e8 1 60000000 lovelace + TxOutDatumNone\n", | |
"dbe16e67d5c294c589f74f90af34877095a731209386fc81fe493f64f6861474 0 10000000000 lovelace + TxOutDatumNone\n" | |
] | |
} | |
], | |
"source": [ | |
"cardano-cli query utxo --testnet-magic $MAGIC --address $ADDRESS_P" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "1cc04f20-1e34-4af7-bfae-27b0b4e203a5", | |
"metadata": {}, | |
"source": [ | |
"### 4.2. First notification\n", | |
"\n", | |
"Bundle the contract and state, computing the redeemer, datum, and script." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 52, | |
"id": "ed96f465-d8e7-43d0-ab48-fb27dab83e0a", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"\n", | |
"Bare-validator cost: ExBudget {exBudgetCPU = ExCPU 18515100, exBudgetMemory = ExMemory 80600}\n", | |
"Validator size: 12642\n", | |
"Datum size: 109\n", | |
"Redeemer size: 11\n", | |
"Total size: 12762\n" | |
] | |
} | |
], | |
"source": [ | |
"marlowe-cli contract marlowe --testnet-magic \"$MAGIC\" \\\n", | |
" --input-file reference-script-1.input \\\n", | |
" --contract-file reference-script-2.contract \\\n", | |
" --state-file reference-script-2.state \\\n", | |
" --out-file reference-script-2.marlowe \\\n", | |
" --print-stats" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "7bb78626-c98b-452a-9a0c-30fb5bbb2061", | |
"metadata": {}, | |
"source": [ | |
"Extract the redeemer." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 53, | |
"id": "658412ac-9893-4a34-94fd-4e6d348de111", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"jq '.redeemer.json' reference-script-2.marlowe > reference-script-1.redeemer" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "90e04d69-8e29-4989-9903-a0fda986f55c", | |
"metadata": {}, | |
"source": [ | |
"Extract the datum." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 54, | |
"id": "540eee65-f569-4a53-ab48-e2451dc37846", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"jq '.datum.json' reference-script-2.marlowe > reference-script-2.datum" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "096d57db-fbc4-4819-a6a2-feadae1ef793", | |
"metadata": {}, | |
"source": [ | |
"Build the transaction" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 56, | |
"id": "6907c408-bcb5-4e20-94f6-15a1172253c6", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Estimated transaction fee: Lovelace 432682\n" | |
] | |
} | |
], | |
"source": [ | |
"cardano-cli transaction build --testnet-magic \"$MAGIC\" \\\n", | |
" --babbage-era \\\n", | |
" --protocol-params-file reference-script.protocol \\\n", | |
" --tx-in-collateral \"$TX_2#0\" \\\n", | |
" --tx-in \"$TX_2#0\" \\\n", | |
" --tx-in \"$TX_2#1\" \\\n", | |
" --spending-tx-in-reference \"$TX_1#1\" \\\n", | |
" --spending-plutus-script-v2 \\\n", | |
" --spending-reference-tx-in-datum-file reference-script-1.datum \\\n", | |
" --spending-reference-tx-in-redeemer-file reference-script-1.redeemer \\\n", | |
" --tx-out \"$ADDRESS_S+$ACCOUNT_LOVELACE\" \\\n", | |
" --tx-out-datum-embed-file reference-script-2.datum \\\n", | |
" --change-address \"$ADDRESS_P\" \\\n", | |
" --required-signer \"$PAYMENT_SKEY\" \\\n", | |
" --invalid-before \"$INVALID_BEFORE\" \\\n", | |
" --invalid-hereafter \"$INVALID_HEREAFTER\" \\\n", | |
" --out-file tx-2.raw" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 57, | |
"id": "c17aa203-c7fc-4e1f-9650-253f4c27ab59", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"cardano-cli transaction sign --testnet-magic \"$MAGIC\" \\\n", | |
" --tx-body-file tx-2.raw \\\n", | |
" --signing-key-file \"$PAYMENT_SKEY\" \\\n", | |
" --out-file tx-2.signed" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 58, | |
"id": "bb205a2b-a36f-4969-bc7c-f26792751e78", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Transaction successfully submitted.\n" | |
] | |
} | |
], | |
"source": [ | |
"cardano-cli transaction submit --testnet-magic \"$MAGIC\" \\\n", | |
" --tx-file tx-2.signed" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 66, | |
"id": "d0c1d931-f938-47a9-80dc-521f2c22e53a", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"auxiliary scripts: null\n", | |
"certificates: null\n", | |
"collateral inputs:\n", | |
"- 6dbf4846b98777e9a8348945ceaa673712b38ca65c07e142a6efae3ecf412954#0\n", | |
"era: Babbage\n", | |
"fee: 432682 Lovelace\n", | |
"inputs:\n", | |
"- 6dbf4846b98777e9a8348945ceaa673712b38ca65c07e142a6efae3ecf412954#0\n", | |
"- 6dbf4846b98777e9a8348945ceaa673712b38ca65c07e142a6efae3ecf412954#1\n", | |
"metadata: null\n", | |
"mint: null\n", | |
"outputs:\n", | |
"- address: addr_test1vq9prvx8ufwutkwxx9cmmuuajaqmjqwujqlp9d8pvg6gupczgtm9j\n", | |
" address era: Shelley\n", | |
" amount:\n", | |
" lovelace: 79326112931\n", | |
" datum: null\n", | |
" network: Testnet\n", | |
" payment credential key hash: 0a11b0c7e25dc5d9c63171bdf39d9741b901dc903e12b4e162348e07\n", | |
" reference script: null\n", | |
" stake reference: null\n", | |
"- address: addr_test1wzvmq4tgspn7sdps4dhqf02ta28jetz8drcwpxlaytp0z2ga35plq\n", | |
" address era: Shelley\n", | |
" amount:\n", | |
" lovelace: 3000000\n", | |
" datum:\n", | |
" constructor: 0\n", | |
" fields:\n", | |
" - constructor: 0\n", | |
" fields:\n", | |
" - bytes: ''\n", | |
" - constructor: 0\n", | |
" fields:\n", | |
" - map:\n", | |
" - k:\n", | |
" constructor: 0\n", | |
" fields:\n", | |
" - constructor: 0\n", | |
" fields:\n", | |
" - bytes: 0a11b0c7e25dc5d9c63171bdf39d9741b901dc903e12b4e162348e07\n", | |
" - constructor: 0\n", | |
" fields:\n", | |
" - bytes: ''\n", | |
" - bytes: ''\n", | |
" v:\n", | |
" int: 3000000\n", | |
" - map: []\n", | |
" - map: []\n", | |
" - int: 1663003179000\n", | |
" - constructor: 3\n", | |
" fields:\n", | |
" - list:\n", | |
" - constructor: 0\n", | |
" fields:\n", | |
" - constructor: 2\n", | |
" fields:\n", | |
" - constructor: 9\n", | |
" fields: []\n", | |
" - constructor: 0\n", | |
" fields: []\n", | |
" - int: 1665595179000\n", | |
" - constructor: 0\n", | |
" fields: []\n", | |
" network: Testnet\n", | |
" payment credential script hash: 99b055688067e83430ab6e04bd4bea8f2cac4768f0e09bfd22c2f129\n", | |
" reference script: null\n", | |
" stake reference: null\n", | |
"required signers (payment key hashes needed for scripts):\n", | |
"- 0a11b0c7e25dc5d9c63171bdf39d9741b901dc903e12b4e162348e07\n", | |
"update proposal: null\n", | |
"validity range:\n", | |
" lower bound: 2999979\n", | |
" upper bound: 3017979\n", | |
"withdrawals: null\n", | |
"witnesses:\n", | |
"- key: VKey (VerKeyEd25519DSIGN \"669ed15b1bc5e97ec45af8951e9cbcbd33a3b5878943704d054a1a3ec46be282\")\n", | |
" signature: SignedDSIGN (SigEd25519DSIGN \"863f4f0522c9b397412cf49ae72ecfe9d6d593aad171af1441ee28aa947f9ad9ae25ab53e9841205da282f6a30c9f8377563050440b1d81fb5f8e877e7421705\")\n" | |
] | |
} | |
], | |
"source": [ | |
"cardano-cli transaction view --tx-file tx-2.signed" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "e760743c-4dd9-44c3-9557-6a55f62ecfef", | |
"metadata": {}, | |
"source": [ | |
"Wait for the transaction to be confirmed. (One can check the node logs to see when the confirmation has occurred.)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 60, | |
"id": "876517e7-db09-48ff-84d0-52491db87da0", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
" TxHash TxIx Amount\n", | |
"--------------------------------------------------------------------------------------\n", | |
"040814b28e6741bf8bcca03e9350626e0a2b6c56f180d0f3bdc1b7ed77fd43d2 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"81671bb1d4b81e0eb43263041b831b632eb16c11927b1c33b1c8fe03c8f4d9c3\"\n", | |
"06c30bd4e5b043584e80a67a61b7de3e789266b0fc9497fe0604235e63ad5160 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"132ffdcc65c82939a06ead32edda3d09655161b377f3ff512df1b5166597ca3e\"\n", | |
"09e8f95117ee9d0c773932fd3774148986beeff52c1e945752bee75cdb63a07a 1 25000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"957004e48fcabfa64716e45a8860afbe7ed363ae2110de15080d111436d7513b\"\n", | |
"2a6267fbe3c56ba72f3a06a52e991a74e1fd13f97f5c8ffe6887f6699230ad6b 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"d81828c3915542ae7a8a002993c38b9539ad397843afef82a351c9efd6b73902\"\n", | |
"2cf9a5f40cf8f18f841c2982cfb3eae8e372766d74293189338ba3788e34482e 1 25000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"3a2104612975fc5c9c2dd9f12172985e03d97cf8fd8a8142ed2ef28aa425a611\"\n", | |
"2f3ee57755eb7fed435f97d03906122dea73104e5b312fcc84e9747ca521861f 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"02bbdfac4d3b298b06a4ee907636fdb075b1a668295102a55d3d1df3112e02f3\"\n", | |
"305023f885ddcddcc919beda109226dd05ce4a56674e6bf21ad94a1d05489b74 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"a7cc909f7eefb07e23b61a2e106701f8f484120cf82cf1d1b1f886c41d070624\"\n", | |
"339daf8dac93eb1fcd4cc2c5319c0d6560bce72cdae5220c10a7f474c5c9f1b4 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"9fc2fd5b6dac9cf01b6f37c7f0beb6356d5a8750735623fc872cf32da828613b\"\n", | |
"3987bab0d1e1e12f7b6a66f69658e4b05e1b37104aebc44d01ffaf651f055190 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"ca903111ac28eb71f8deede53049045f57b8f7a43f6f2551083bdc2dcf903f43\"\n", | |
"3f0aaacf43b65c1e7a714d75eb1dc795cc5bfc918e8f775027d00c22cd9ff90d 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"662bd442551ff081481da1004ca26f561c42ca8238576b88ce977f57d9df7587\"\n", | |
"4903d88090972f231beecf0d993728baf8d4ab101e3ff43c97b9baf6c9c118fe 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"b3aeae799f4aee5d7410595c7476844798408ad5d756ec1295ecad74fb3e8828\"\n", | |
"565759233ab826ab3b17535f52244ef5a91ac8820b76193ad1dfa778f86a036e 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"a4533d7298ecc158f4f1921853cca0df90ee93225b9d31451254fc6a366b972f\"\n", | |
"592d44a3092994f4429606aeed6fcabc38344e5fcc7a1d383a46d37fddef10d9 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"befa82c806a7a26822b9713d06ae7e333a107e18df3fb1c7b73745b2f846c6ef\"\n", | |
"69073b20501d2c50e8019e5eccd716a46364b221b8c318cd4ebae6a52c0d1cbc 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"a757c6cb4cafa33e8578dfddf7b5c75931f8fb327180a3d15dac125a239914eb\"\n", | |
"6b5963bf6cb7207851a34d896776d371ef9a645107cf2780b02188dba73d39cf 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"689513c315308df35bc15c3bbfe2a15da7e0048c4412523f62cb0a4277a2b461\"\n", | |
"7254e1a0bf50723f624576ca92ed1bd10d8bcaee7f40f723e71ff6515035c4a8 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"5c32953f3cb9e2f8b018a8f05b0b031962f2563363e2d2bde92709574e132617\"\n", | |
"76d1a24ee496dcfaa936b6f0d0103f525abdcc6efda6e1c7930c35990625f739 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"085e014d829aacbcb9d653e63a1dfeffaf1e49b7902c8e7f30a2e40136e27b65\"\n", | |
"948cf549e85061c9857b2649667eecee8414cc1bbc4a04e3c0ce1fb26bde0123 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"c6c96d1f12c68bac0c8d9ad3bf2643bd32509a5f5cf58a3f7524f82c822c5253\"\n", | |
"9b65472a550b5efa1ed4eeafc48fccb24b93852f6213ba15a5347ffe064f252f 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"f288178de30b7569c7ac13a687ad110c46fb6f965a7ac5d30dec5b6273db1fc9\"\n", | |
"a732afff25560cdb9d246810a29f070d39c6e28cc7c3c99de00af06f344f2183 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"c239e9811a0bf0a21356a1627201e597651537b7a13a05da161fc57daaee243c\"\n", | |
"acd8d2090a2075fcb493511e16e6a65a3b39f0d7ef9289f743fc923d9c03d6fe 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"8f153f30984a90d35a310529013ed6431bedf9f727c0404a2838d351d8812e04\"\n", | |
"af851b7d0decd22db221461e0bc33a1bd2784a485b5f0f52e469ebf430402e11 1 3000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"f76803d07e761105e306773fee3be8b57051213f2241e4cb1d5c03832a7c48b2\"\n", | |
"b336de6edf70b537f8f9b67ac6c8c6360df5333b8ae5289cfe4ddcedfc7dece4 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"44a2053a41d627219383994f01affccf8a75ea4b4c9f369499d2dd864f9f5106\"\n", | |
"ba21f2ad50ed6af048114566eb577116303c099b512c55330387f2d76927ca0e 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"18caf27a5b8ef0856926b53e22bc71a80fb2b7e2c20e7484b4b72efaef7bbb7a\"\n", | |
"c47a0a633416eda2cd1e5f23857146691e31bf384732286959b0d7cdcdb5dd83 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"87fbf89da6c03879de9c4719d09acc7f20a192bb5cb704ed55aade4d65b6afe8\"\n", | |
"cb94a8869eec4ab7f40113f05f8a7a933118e2bbd140f8c1063123148004f734 1 25000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"395526da0e084e06ef5da074c119c34fe6720dd715e710e178122ffc5f93098d\"\n", | |
"d3074e879db9616d5a1fb6754f677f37a798a42dde3e173b18703c2a782988aa 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"268e7f8b2d2fcb95fb8fc5c6f08a944d5ac0d060048609cc85a3448c65b5e834\"\n", | |
"d3dbd9b9815dcfc550c8d6921cb4f84730b6f4abebc4b84274399406517cab24 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"1c1d63d52ecb6bcf7fef9854ba5a99579661198e5ecec6a0258926d85f7907a9\"\n", | |
"dadf5f352f6465c16cc851f9bfba0c07a4028e7f7116612f1c55fe5395fbe9e0 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"29f76491688b4262a8da0bb773cb133894851cb9aeb28add9efded1022e58cd2\"\n", | |
"de7e2c7d9e5806e46f9219aecbc2c979df8c95687fa0468a1d303d0c7c9a0c98 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"609c954f67e16322ea42224c23ddfeae843b22325c2e49ff306010398753cfc7\"\n", | |
"e87462f313b2c1ee339150a8c3f08cd6d3c33f7a6d398e6ad045ea8bab1694ff 1 25000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"d001bad4f5f472f52200be1f209487a4ecd7951ec9a0416dae7fbfe6b6915eae\"\n", | |
"e987e1eecaf62f4de13beeec628989f185536c32876130fd08f657c3b9920fa1 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"d24c24a2fcea50f54e3cd9993acde5667fe0467a221da982d553ed1b1ab592e6\"\n", | |
"f6e78eb0df3c1aeee814cc11654326ab1eda06cef267ed01d4ea30701c8cc331 1 25000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"55f8e2e8125a464b36422f2ce4c4ae48389a9cfffd0e51612a894cd05619595d\"\n", | |
"fdb1aa1dd35941eba955c1caa4c3b3935e443dc685012d89eb0ec3469b51e347 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"8010cd1479847668424f6cf148b1bd31e073bdd91980e7d17e93527bc0482b07\"\n", | |
"ff8b3fafbae455568b8181c2b291b26189a14e1d1fe47873c4ff8cb32602e567 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"61b27c02ee14f93a0da5ecdd9f363cc02f8ab192c01c1f0dd1169abccd4291af\"\n" | |
] | |
} | |
], | |
"source": [ | |
"cardano-cli query utxo --testnet-magic $MAGIC --address $ADDRESS_S" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "a23db1b9-481e-4f6f-bc04-fd7850303e88", | |
"metadata": {}, | |
"source": [ | |
"Record the transaction ID." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 67, | |
"id": "eff58c73-91a2-4631-9607-d12e3c6e06b7", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"TX_3=af851b7d0decd22db221461e0bc33a1bd2784a485b5f0f52e469ebf430402e11" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "9cb79a7f-669d-44c6-83a3-5e7f862bd651", | |
"metadata": {}, | |
"source": [ | |
"See that the change has been received" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 63, | |
"id": "d60ba964-117e-463c-a5b8-92fc7350e52a", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
" TxHash TxIx Amount\n", | |
"--------------------------------------------------------------------------------------\n", | |
"601071672677ba341e94bc634d993bc2b5c85d43121d8735895a01456bb8130e 0 10000000000 lovelace + TxOutDatumNone\n", | |
"6b452603f7aecf73211c300d5fd1b55f8027114b52a3e6cda2e36efeef3029dc 1 79340618605 lovelace + TxOutDatumNone\n", | |
"8909aeefb0cd4c4410e9e7566ef20db6888b23d26c0825f58c98a9d7445a01c1 0 533936067 lovelace + TxOutDatumNone\n", | |
"8f972918dd0be3f197abbbad98c82c4c033299291ac1dc434bdeaf679b8d7d75 0 164824769 lovelace + TxOutDatumNone\n", | |
"af851b7d0decd22db221461e0bc33a1bd2784a485b5f0f52e469ebf430402e11 0 79326112931 lovelace + TxOutDatumNone\n", | |
"c02630ec7268939fa03028248f9287bb00c08ac44357d485df062f460b6734e8 1 60000000 lovelace + TxOutDatumNone\n", | |
"dbe16e67d5c294c589f74f90af34877095a731209386fc81fe493f64f6861474 0 10000000000 lovelace + TxOutDatumNone\n" | |
] | |
} | |
], | |
"source": [ | |
"cardano-cli query utxo --testnet-magic $MAGIC --address $ADDRESS_P" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "98991b6b-09a5-48b3-9582-805288182d82", | |
"metadata": {}, | |
"source": [ | |
"### 4.3. Second notification\n", | |
"\n", | |
"Bundle the contract and state, computing the redeemer, datum, and script." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 68, | |
"id": "337c32fb-2201-4cf7-a6b7-a0b5a4947d2a", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"\n", | |
"Bare-validator cost: ExBudget {exBudgetCPU = ExCPU 18515100, exBudgetMemory = ExMemory 80600}\n", | |
"Validator size: 12642\n", | |
"Datum size: 30\n", | |
"Redeemer size: 11\n", | |
"Total size: 12683\n" | |
] | |
} | |
], | |
"source": [ | |
"marlowe-cli contract marlowe --testnet-magic \"$MAGIC\" \\\n", | |
" --input-file reference-script-2.input \\\n", | |
" --contract-file reference-script-3.contract \\\n", | |
" --state-file reference-script-3.state \\\n", | |
" --out-file reference-script-3.marlowe \\\n", | |
" --print-stats" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "b45580ba-6cf0-4ed7-8adc-aa1253966327", | |
"metadata": {}, | |
"source": [ | |
"Extract the redeemer." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 69, | |
"id": "4cd84732-95a4-422c-9d40-b1dd330a6ada", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"jq '.redeemer.json' reference-script-3.marlowe > reference-script-2.redeemer" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "3d8c7bd9-85e5-4b6e-8fcd-d119c67d180c", | |
"metadata": {}, | |
"source": [ | |
"No datum is needed because the contract does not continue." | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "c8dce40e-4b4a-4c01-84e3-cebf6c7f5a28", | |
"metadata": {}, | |
"source": [ | |
"Build the transaction" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 70, | |
"id": "c808a913-eac5-4bc3-b96b-dd0799f9b745", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Estimated transaction fee: Lovelace 365677\n" | |
] | |
} | |
], | |
"source": [ | |
"cardano-cli transaction build --testnet-magic \"$MAGIC\" \\\n", | |
" --babbage-era \\\n", | |
" --protocol-params-file reference-script.protocol \\\n", | |
" --tx-in-collateral \"$TX_3#0\" \\\n", | |
" --tx-in \"$TX_3#0\" \\\n", | |
" --tx-in \"$TX_3#1\" \\\n", | |
" --spending-tx-in-reference \"$TX_1#1\" \\\n", | |
" --spending-plutus-script-v2 \\\n", | |
" --spending-reference-tx-in-datum-file reference-script-2.datum \\\n", | |
" --spending-reference-tx-in-redeemer-file reference-script-2.redeemer \\\n", | |
" --tx-out \"$ADDRESS_P+$ACCOUNT_LOVELACE\" \\\n", | |
" --change-address \"$ADDRESS_P\" \\\n", | |
" --required-signer \"$PAYMENT_SKEY\" \\\n", | |
" --invalid-before \"$INVALID_BEFORE\" \\\n", | |
" --invalid-hereafter \"$INVALID_HEREAFTER\" \\\n", | |
" --out-file tx-3.raw" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "90bb0abb-d8b7-450c-ab46-a5dab558ec21", | |
"metadata": {}, | |
"source": [ | |
"Sign and submit the transaction." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 71, | |
"id": "9fcfe7b1-a883-455b-b981-7336a8571f9e", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"cardano-cli transaction sign --testnet-magic \"$MAGIC\" \\\n", | |
" --tx-body-file tx-3.raw \\\n", | |
" --signing-key-file \"$PAYMENT_SKEY\" \\\n", | |
" --out-file tx-3.signed" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 73, | |
"id": "f6effc77-71f6-497e-a132-b52201211ca0", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Transaction successfully submitted.\n" | |
] | |
} | |
], | |
"source": [ | |
"cardano-cli transaction submit --testnet-magic \"$MAGIC\" \\\n", | |
" --tx-file tx-3.signed" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 77, | |
"id": "12b8a3c8-9c91-4823-8901-5000ca6387bd", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"auxiliary scripts: null\n", | |
"certificates: null\n", | |
"collateral inputs:\n", | |
"- af851b7d0decd22db221461e0bc33a1bd2784a485b5f0f52e469ebf430402e11#0\n", | |
"era: Babbage\n", | |
"fee: 365677 Lovelace\n", | |
"inputs:\n", | |
"- af851b7d0decd22db221461e0bc33a1bd2784a485b5f0f52e469ebf430402e11#0\n", | |
"- af851b7d0decd22db221461e0bc33a1bd2784a485b5f0f52e469ebf430402e11#1\n", | |
"metadata: null\n", | |
"mint: null\n", | |
"outputs:\n", | |
"- address: addr_test1vq9prvx8ufwutkwxx9cmmuuajaqmjqwujqlp9d8pvg6gupczgtm9j\n", | |
" address era: Shelley\n", | |
" amount:\n", | |
" lovelace: 79325747254\n", | |
" datum: null\n", | |
" network: Testnet\n", | |
" payment credential key hash: 0a11b0c7e25dc5d9c63171bdf39d9741b901dc903e12b4e162348e07\n", | |
" reference script: null\n", | |
" stake reference: null\n", | |
"- address: addr_test1vq9prvx8ufwutkwxx9cmmuuajaqmjqwujqlp9d8pvg6gupczgtm9j\n", | |
" address era: Shelley\n", | |
" amount:\n", | |
" lovelace: 3000000\n", | |
" datum: null\n", | |
" network: Testnet\n", | |
" payment credential key hash: 0a11b0c7e25dc5d9c63171bdf39d9741b901dc903e12b4e162348e07\n", | |
" reference script: null\n", | |
" stake reference: null\n", | |
"required signers (payment key hashes needed for scripts):\n", | |
"- 0a11b0c7e25dc5d9c63171bdf39d9741b901dc903e12b4e162348e07\n", | |
"update proposal: null\n", | |
"validity range:\n", | |
" lower bound: 2999979\n", | |
" upper bound: 3017979\n", | |
"withdrawals: null\n", | |
"witnesses:\n", | |
"- key: VKey (VerKeyEd25519DSIGN \"669ed15b1bc5e97ec45af8951e9cbcbd33a3b5878943704d054a1a3ec46be282\")\n", | |
" signature: SignedDSIGN (SigEd25519DSIGN \"4a17b3f81e5087fb0424b6ca4cf5fb146b2d4cd0fea83ea09216ad8bdae58fc4c7e088bd63d5ef93a8d3fa7610950a754e00b910afcb1a636a66cd07d68b7e02\")\n" | |
] | |
} | |
], | |
"source": [ | |
"cardano-cli transaction view --tx-file tx-3.signed" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "922c5f8c-30bb-45f4-ad54-ade542f8c5a1", | |
"metadata": {}, | |
"source": [ | |
"Wait for the transaction to be confirmed. (One can check the node logs to see when the confirmation has occurred.)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "178e0600-da25-47b3-b536-7ebceb1d1670", | |
"metadata": {}, | |
"source": [ | |
"See that there is no UTxO at the script address." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 74, | |
"id": "9b4e63f1-2123-4f94-8d82-1c167014954d", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
" TxHash TxIx Amount\n", | |
"--------------------------------------------------------------------------------------\n", | |
"040814b28e6741bf8bcca03e9350626e0a2b6c56f180d0f3bdc1b7ed77fd43d2 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"81671bb1d4b81e0eb43263041b831b632eb16c11927b1c33b1c8fe03c8f4d9c3\"\n", | |
"06c30bd4e5b043584e80a67a61b7de3e789266b0fc9497fe0604235e63ad5160 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"132ffdcc65c82939a06ead32edda3d09655161b377f3ff512df1b5166597ca3e\"\n", | |
"09e8f95117ee9d0c773932fd3774148986beeff52c1e945752bee75cdb63a07a 1 25000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"957004e48fcabfa64716e45a8860afbe7ed363ae2110de15080d111436d7513b\"\n", | |
"2a6267fbe3c56ba72f3a06a52e991a74e1fd13f97f5c8ffe6887f6699230ad6b 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"d81828c3915542ae7a8a002993c38b9539ad397843afef82a351c9efd6b73902\"\n", | |
"2cf9a5f40cf8f18f841c2982cfb3eae8e372766d74293189338ba3788e34482e 1 25000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"3a2104612975fc5c9c2dd9f12172985e03d97cf8fd8a8142ed2ef28aa425a611\"\n", | |
"2f3ee57755eb7fed435f97d03906122dea73104e5b312fcc84e9747ca521861f 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"02bbdfac4d3b298b06a4ee907636fdb075b1a668295102a55d3d1df3112e02f3\"\n", | |
"305023f885ddcddcc919beda109226dd05ce4a56674e6bf21ad94a1d05489b74 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"a7cc909f7eefb07e23b61a2e106701f8f484120cf82cf1d1b1f886c41d070624\"\n", | |
"339daf8dac93eb1fcd4cc2c5319c0d6560bce72cdae5220c10a7f474c5c9f1b4 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"9fc2fd5b6dac9cf01b6f37c7f0beb6356d5a8750735623fc872cf32da828613b\"\n", | |
"3987bab0d1e1e12f7b6a66f69658e4b05e1b37104aebc44d01ffaf651f055190 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"ca903111ac28eb71f8deede53049045f57b8f7a43f6f2551083bdc2dcf903f43\"\n", | |
"3f0aaacf43b65c1e7a714d75eb1dc795cc5bfc918e8f775027d00c22cd9ff90d 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"662bd442551ff081481da1004ca26f561c42ca8238576b88ce977f57d9df7587\"\n", | |
"4903d88090972f231beecf0d993728baf8d4ab101e3ff43c97b9baf6c9c118fe 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"b3aeae799f4aee5d7410595c7476844798408ad5d756ec1295ecad74fb3e8828\"\n", | |
"565759233ab826ab3b17535f52244ef5a91ac8820b76193ad1dfa778f86a036e 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"a4533d7298ecc158f4f1921853cca0df90ee93225b9d31451254fc6a366b972f\"\n", | |
"592d44a3092994f4429606aeed6fcabc38344e5fcc7a1d383a46d37fddef10d9 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"befa82c806a7a26822b9713d06ae7e333a107e18df3fb1c7b73745b2f846c6ef\"\n", | |
"69073b20501d2c50e8019e5eccd716a46364b221b8c318cd4ebae6a52c0d1cbc 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"a757c6cb4cafa33e8578dfddf7b5c75931f8fb327180a3d15dac125a239914eb\"\n", | |
"6b5963bf6cb7207851a34d896776d371ef9a645107cf2780b02188dba73d39cf 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"689513c315308df35bc15c3bbfe2a15da7e0048c4412523f62cb0a4277a2b461\"\n", | |
"7254e1a0bf50723f624576ca92ed1bd10d8bcaee7f40f723e71ff6515035c4a8 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"5c32953f3cb9e2f8b018a8f05b0b031962f2563363e2d2bde92709574e132617\"\n", | |
"76d1a24ee496dcfaa936b6f0d0103f525abdcc6efda6e1c7930c35990625f739 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"085e014d829aacbcb9d653e63a1dfeffaf1e49b7902c8e7f30a2e40136e27b65\"\n", | |
"948cf549e85061c9857b2649667eecee8414cc1bbc4a04e3c0ce1fb26bde0123 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"c6c96d1f12c68bac0c8d9ad3bf2643bd32509a5f5cf58a3f7524f82c822c5253\"\n", | |
"9b65472a550b5efa1ed4eeafc48fccb24b93852f6213ba15a5347ffe064f252f 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"f288178de30b7569c7ac13a687ad110c46fb6f965a7ac5d30dec5b6273db1fc9\"\n", | |
"a732afff25560cdb9d246810a29f070d39c6e28cc7c3c99de00af06f344f2183 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"c239e9811a0bf0a21356a1627201e597651537b7a13a05da161fc57daaee243c\"\n", | |
"acd8d2090a2075fcb493511e16e6a65a3b39f0d7ef9289f743fc923d9c03d6fe 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"8f153f30984a90d35a310529013ed6431bedf9f727c0404a2838d351d8812e04\"\n", | |
"b336de6edf70b537f8f9b67ac6c8c6360df5333b8ae5289cfe4ddcedfc7dece4 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"44a2053a41d627219383994f01affccf8a75ea4b4c9f369499d2dd864f9f5106\"\n", | |
"ba21f2ad50ed6af048114566eb577116303c099b512c55330387f2d76927ca0e 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"18caf27a5b8ef0856926b53e22bc71a80fb2b7e2c20e7484b4b72efaef7bbb7a\"\n", | |
"c47a0a633416eda2cd1e5f23857146691e31bf384732286959b0d7cdcdb5dd83 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"87fbf89da6c03879de9c4719d09acc7f20a192bb5cb704ed55aade4d65b6afe8\"\n", | |
"cb94a8869eec4ab7f40113f05f8a7a933118e2bbd140f8c1063123148004f734 1 25000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"395526da0e084e06ef5da074c119c34fe6720dd715e710e178122ffc5f93098d\"\n", | |
"d3074e879db9616d5a1fb6754f677f37a798a42dde3e173b18703c2a782988aa 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"268e7f8b2d2fcb95fb8fc5c6f08a944d5ac0d060048609cc85a3448c65b5e834\"\n", | |
"d3dbd9b9815dcfc550c8d6921cb4f84730b6f4abebc4b84274399406517cab24 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"1c1d63d52ecb6bcf7fef9854ba5a99579661198e5ecec6a0258926d85f7907a9\"\n", | |
"dadf5f352f6465c16cc851f9bfba0c07a4028e7f7116612f1c55fe5395fbe9e0 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"29f76491688b4262a8da0bb773cb133894851cb9aeb28add9efded1022e58cd2\"\n", | |
"de7e2c7d9e5806e46f9219aecbc2c979df8c95687fa0468a1d303d0c7c9a0c98 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"609c954f67e16322ea42224c23ddfeae843b22325c2e49ff306010398753cfc7\"\n", | |
"e87462f313b2c1ee339150a8c3f08cd6d3c33f7a6d398e6ad045ea8bab1694ff 1 25000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"d001bad4f5f472f52200be1f209487a4ecd7951ec9a0416dae7fbfe6b6915eae\"\n", | |
"e987e1eecaf62f4de13beeec628989f185536c32876130fd08f657c3b9920fa1 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"d24c24a2fcea50f54e3cd9993acde5667fe0467a221da982d553ed1b1ab592e6\"\n", | |
"f6e78eb0df3c1aeee814cc11654326ab1eda06cef267ed01d4ea30701c8cc331 1 25000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"55f8e2e8125a464b36422f2ce4c4ae48389a9cfffd0e51612a894cd05619595d\"\n", | |
"fdb1aa1dd35941eba955c1caa4c3b3935e443dc685012d89eb0ec3469b51e347 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"8010cd1479847668424f6cf148b1bd31e073bdd91980e7d17e93527bc0482b07\"\n", | |
"ff8b3fafbae455568b8181c2b291b26189a14e1d1fe47873c4ff8cb32602e567 1 10000000 lovelace + TxOutDatumHash ScriptDataInBabbageEra \"61b27c02ee14f93a0da5ecdd9f363cc02f8ab192c01c1f0dd1169abccd4291af\"\n" | |
] | |
} | |
], | |
"source": [ | |
"cardano-cli query utxo --testnet-magic $MAGIC --address $ADDRESS_S" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "13f16450-660c-441e-b05e-02bf32f65b54", | |
"metadata": {}, | |
"source": [ | |
"See that the payment and change has been received." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 75, | |
"id": "4f7f0f2f-16c1-41a7-89fb-2769ee225a05", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
" TxHash TxIx Amount\n", | |
"--------------------------------------------------------------------------------------\n", | |
"3e29055316cbc15df3515f53a53456f3f889b704b7a4608e53e2a36366483f5e 0 79325747254 lovelace + TxOutDatumNone\n", | |
"3e29055316cbc15df3515f53a53456f3f889b704b7a4608e53e2a36366483f5e 1 3000000 lovelace + TxOutDatumNone\n", | |
"601071672677ba341e94bc634d993bc2b5c85d43121d8735895a01456bb8130e 0 10000000000 lovelace + TxOutDatumNone\n", | |
"6b452603f7aecf73211c300d5fd1b55f8027114b52a3e6cda2e36efeef3029dc 1 79340618605 lovelace + TxOutDatumNone\n", | |
"8909aeefb0cd4c4410e9e7566ef20db6888b23d26c0825f58c98a9d7445a01c1 0 533936067 lovelace + TxOutDatumNone\n", | |
"8f972918dd0be3f197abbbad98c82c4c033299291ac1dc434bdeaf679b8d7d75 0 164824769 lovelace + TxOutDatumNone\n", | |
"c02630ec7268939fa03028248f9287bb00c08ac44357d485df062f460b6734e8 1 60000000 lovelace + TxOutDatumNone\n", | |
"dbe16e67d5c294c589f74f90af34877095a731209386fc81fe493f64f6861474 0 10000000000 lovelace + TxOutDatumNone\n" | |
] | |
} | |
], | |
"source": [ | |
"cardano-cli query utxo --testnet-magic $MAGIC --address $ADDRESS_P" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 76, | |
"id": "5d9d94a1-e8df-4560-9959-b74634492e72", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"TX_3=3e29055316cbc15df3515f53a53456f3f889b704b7a4608e53e2a36366483f5e" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Bash - Marlowe", | |
"language": "bash", | |
"name": "bash_marlowe" | |
}, | |
"language_info": { | |
"codemirror_mode": "shell", | |
"file_extension": ".sh", | |
"mimetype": "text/x-sh", | |
"name": "/nix/store/zwjm0gln1vk7x1akpyz0yxjsd1yc46gi-bash-5.1-p16/bin/bash" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment