Last active
August 24, 2023 15:31
-
-
Save bwbush/119c5d833285af2d129712742fffdb99 to your computer and use it in GitHub Desktop.
Setup Marlowe Payout
This file contains 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": "code", | |
"execution_count": 1, | |
"id": "bd09f250-e8aa-41c4-8e1e-c8241c5f062b", | |
"metadata": { | |
"tags": [] | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"CARDANO_NODE_SOCKET_PATH = /extra/iohk/networks/preprod/node.socket\n", | |
"CARDANO_TESTNET_MAGIC = 1\n" | |
] | |
} | |
], | |
"source": [ | |
". /extra/iohk/networks/preprod/configure.env\n", | |
"echo \"CARDANO_NODE_SOCKET_PATH = $CARDANO_NODE_SOCKET_PATH\"\n", | |
"echo \"CARDANO_TESTNET_MAGIC = $CARDANO_TESTNET_MAGIC\"" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"id": "f6b03d7d-9872-4751-9086-c0d2ad3389e0", | |
"metadata": { | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"PAYMENT_SKEY=/extra/iohk/networks/treasury/payment.skey\n", | |
"PAYMENT_ADDR=$(cat /extra/iohk/networks/treasury/payment.testnet.address)\n", | |
"ROLE_CURRENCY=8bb3b343d8e404472337966a722150048c768d0a92a9813596c5338d\n", | |
"ROLE_NAME=1stPrize" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"id": "c39faf54-059b-4e81-a856-af4bc397fbf4", | |
"metadata": { | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"cat << EOI > contract.json\n", | |
"\"close\"\n", | |
"EOI" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"id": "09986321-3871-4231-896e-04b9924eb851", | |
"metadata": { | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"cat << EOI > state.json\n", | |
"{\n", | |
" \"accounts\" : [\n", | |
" [\n", | |
" [\n", | |
" \"role_token\" : \"$ROLE_NAME\"\n", | |
" , {\"currency_symbol\":\"\",\"token_name\":\"\"}\n", | |
" ]\n", | |
" , 5000000\n", | |
" ]\n", | |
" ]\n", | |
", \"choices\" : []\n", | |
", \"boundValues\" : []\n", | |
", \"minTime\" : 1\n", | |
"}\n", | |
"EOI" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"id": "c73d68b8-b24e-43d2-986e-ffac228f7725", | |
"metadata": { | |
"tags": [] | |
}, | |
"outputs": [], | |
"source": [ | |
"marlowe-cli run initialize \\\n", | |
" --contract-file contract.json \\\n", | |
" --state-file state.json \\\n", | |
" --out-file marlowe-1.json \\\n", | |
" --roles-currency \"$ROLE_CURRENCY\" \\\n", | |
" --permanently-without-staking" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"id": "1caaab5b-468a-4627-be34-f57bb9bd56ac", | |
"metadata": { | |
"tags": [] | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"CONTRACT_ID = 85f0e180a8aa01881d5e49529111785f3022578db9272e2a51d5e4a1f61fa881#1\n" | |
] | |
} | |
], | |
"source": [ | |
"CONTRACT_ID=$(\n", | |
"marlowe-cli run auto-execute \\\n", | |
" --marlowe-out-file marlowe-1.json \\\n", | |
" --change-address \"$PAYMENT_ADDR\" \\\n", | |
" --required-signer \"$PAYMENT_SKEY\" \\\n", | |
" --out-file tx-1.unsigned \\\n", | |
" --submit 600s \\\n", | |
"| sed -e 's/^TxId \"\\(.*\\)\"$/\\1#1/' \\\n", | |
")\n", | |
"echo \"CONTRACT_ID = $CONTRACT_ID\"" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"id": "c0d24ae3-6212-49b4-bf52-a7c83820b258", | |
"metadata": { | |
"tags": [] | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Rounding `TransactionInput` txInterval boundries to:(POSIXTime {getPOSIXTime = 1692890760000},POSIXTime {getPOSIXTime = 1692891000999})\n", | |
"TransactionInput {txInterval = (POSIXTime {getPOSIXTime = 1692890760000},POSIXTime {getPOSIXTime = 1692891000999}), txInputs = []}\n" | |
] | |
} | |
], | |
"source": [ | |
"marlowe-cli run prepare \\\n", | |
" --marlowe-file marlowe-1.json \\\n", | |
" --out-file marlowe-2.json \\\n", | |
" --invalid-before \"$((1000 * ($(date -u +%s) - 1 * 60)))\" \\\n", | |
" --invalid-hereafter \"$((1000 * ($(date -u +%s) + 3 * 60)))\"" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"id": "a267c97a-5bae-48a2-b3e3-f183dcc2c4c6", | |
"metadata": { | |
"tags": [] | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"TX_ID = 209e9d7553c099ff59f06d49859b0ea910ff7102283890a867266a06a63648ee\n" | |
] | |
} | |
], | |
"source": [ | |
"TX_ID=$(\n", | |
"marlowe-cli run auto-execute \\\n", | |
" --tx-in-marlowe \"$CONTRACT_ID\" \\\n", | |
" --marlowe-in-file marlowe-1.json \\\n", | |
" --marlowe-out-file marlowe-2.json \\\n", | |
" --change-address \"$PAYMENT_ADDR\" \\\n", | |
" --required-signer \"$PAYMENT_SKEY\" \\\n", | |
" --out-file tx-2.unsigned \\\n", | |
" --submit 600s \\\n", | |
"| sed -e 's/^TxId \"\\(.*\\)\"$/\\1/' \\\n", | |
")\n", | |
"echo \"TX_ID = $TX_ID\"" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"id": "acd65c0b-1472-496a-946d-74d5addbe565", | |
"metadata": { | |
"tags": [] | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"https://preprod.cardanoscan.io/transaction/209e9d7553c099ff59f06d49859b0ea910ff7102283890a867266a06a63648ee?tab=utxo\n" | |
] | |
} | |
], | |
"source": [ | |
"echo \"https://preprod.cardanoscan.io/transaction/$TX_ID?tab=utxo\"" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Bash with Marlowe Tools", | |
"language": "bash", | |
"name": "bash-minimal" | |
}, | |
"language_info": { | |
"codemirror_mode": "shell", | |
"file_extension": ".sh", | |
"mimetype": "text/x-sh", | |
"name": "bash" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment