Skip to content

Commit

Permalink
PLT-3027 Added escrow lesson.
Browse files Browse the repository at this point in the history
  • Loading branch information
bwbush committed Mar 16, 2023
1 parent 4eaac24 commit 85424a8
Show file tree
Hide file tree
Showing 9 changed files with 3,305 additions and 34 deletions.
121 changes: 107 additions & 14 deletions 00-preliminaries.ipynb
Expand Up @@ -335,11 +335,11 @@
"name": "stdout",
"output_type": "stream",
"text": [
"block: 728210\n",
"block: 731649\n",
"epoch: 57\n",
"era: Babbage\n",
"hash: 7bdedcb169e17268b48669ac469b1901b702cab7014a5ef6c00011d7e7bcda2a\n",
"slot: 23218657\n",
"hash: ad9ed62386341677ada848804618b6198c1d4187a0bfbd008500d2ef9595943b\n",
"slot: 23307149\n",
"syncProgress: '100.00'\n"
]
}
Expand Down Expand Up @@ -414,7 +414,7 @@
"output_type": "stream",
"text": [
"HTTP/1.1 200 OK\n",
"\u001b[1mDate\u001b[0m: Wed, 15 Mar 2023 17:38:17 GMT\n",
"\u001b[1mDate\u001b[0m: Thu, 16 Mar 2023 18:12:51 GMT\n",
"\u001b[1mServer\u001b[0m: Warp/3.3.24\n",
"\u001b[1mContent-Type\u001b[0m: application/json;charset=utf-8\n",
"\n"
Expand Down Expand Up @@ -689,6 +689,87 @@
"echo \"BORROWER_ADDR = $BORROWER_ADDR\""
]
},
{
"cell_type": "markdown",
"id": "a888e3e6-bdab-4763-8f7f-5c72c990ea90",
"metadata": {},
"source": [
"### The Mediator\n",
"\n",
"Set the file names for this party's signing key and verification key."
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "89967b6a-01a0-42a6-ba70-258f67a2ddba",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"MEDIATOR_SKEY=keys/mediator.skey\n",
"MEDIATOR_VKEY=keys/mediator.vkey"
]
},
{
"cell_type": "markdown",
"id": "40dd9cf7-5931-47a4-a6c3-6bfcc7031963",
"metadata": {},
"source": [
"Generate the keys if they haven't already been generated."
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "81238600-8ae9-43fd-881f-5bb1ab85688d",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"if [[ ! -e \"$MEDIATOR_SKEY\" ]]\n",
"then\n",
" cardano-cli address key-gen \\\n",
" --signing-key-file \"$MEDIATOR_SKEY\" \\\n",
" --verification-key-file \"$MEDIATOR_VKEY\"\n",
"fi"
]
},
{
"cell_type": "markdown",
"id": "8ddf1475-a5a1-4d63-a83d-311cb7391500",
"metadata": {},
"source": [
"Compute the party's address on the testnet."
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "16cd8dd9-153c-4abc-903e-a91e742044ca",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"MEDIATOR_ADDR = addr_test1vr6tytqs3x8qgewhw89m3xrz58t3tqu2hfsecw0u06lf3hg052wsv\n"
]
}
],
"source": [
"MEDIATOR_ADDR=$(cardano-cli address build --testnet-magic \"$CARDANO_TESTNET_MAGIC\" --payment-verification-key-file \"$MEDIATOR_VKEY\" )\n",
"if [[ ! -e keys/mediator.address ]]\n",
"then\n",
" echo \"$MEDIATOR_ADDR\" > keys/mediator.address\n",
"fi\n",
"echo \"MEDIATOR_ADDR = $MEDIATOR_ADDR\""
]
},
{
"cell_type": "markdown",
"id": "74ea3de1-6c14-4ef6-a5ab-e8784cc879cc",
Expand All @@ -705,7 +786,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 21,
"id": "73e739b1-9d2f-4f36-b1ce-24e9e6c88f4b",
"metadata": {
"tags": []
Expand Down Expand Up @@ -735,7 +816,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 22,
"id": "7c2069be-6817-4193-90bf-fd2a5fb26de7",
"metadata": {
"tags": []
Expand All @@ -746,13 +827,15 @@
"output_type": "stream",
"text": [
"LENDER_ADDR = addr_test1vqd3yrtjyx49uld43lvwqaf7z4k03su8gf2x4yr7syzvckgfzm4ck\n",
"BORROWER_ADDR = addr_test1vpy4n4peh4suv0y55yptur0066j5kds8r4ncnuzm0vpzfgg0dhz6d\n"
"BORROWER_ADDR = addr_test1vpy4n4peh4suv0y55yptur0066j5kds8r4ncnuzm0vpzfgg0dhz6d\n",
"MEDIATOR_ADDR = addr_test1vr6tytqs3x8qgewhw89m3xrz58t3tqu2hfsecw0u06lf3hg052wsv\n"
]
}
],
"source": [
"echo \"LENDER_ADDR = $LENDER_ADDR\"\n",
"echo \"BORROWER_ADDR = $BORROWER_ADDR\""
"echo \"BORROWER_ADDR = $BORROWER_ADDR\"\n",
"echo \"MEDIATOR_ADDR = $MEDIATOR_ADDR\""
]
},
{
Expand All @@ -779,7 +862,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 23,
"id": "5bcf4056-963b-41e1-b963-6af2c09498b5",
"metadata": {
"tags": []
Expand All @@ -789,7 +872,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"TxId \"78690d72c67960d4600889d7dd7da2069f14658ed6791c8838dccdd33fe3971f\"\n"
"TxId \"dd3a06e118f9ccfdc6d8721779228d1730a606cf183489e679f2584b4445d883\"\n"
]
}
],
Expand All @@ -808,7 +891,7 @@
" --out-file /dev/null \\\n",
" --source-wallet-credentials \"$FAUCET_ADDR:$FAUCET_SKEY\" \\\n",
" --submit 600 \\\n",
" \"$LENDER_ADDR\" \"$BORROWER_ADDR\""
" \"$LENDER_ADDR\" \"$BORROWER_ADDR\" \"$MEDIATOR_ADDR\""
]
},
{
Expand All @@ -821,7 +904,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 24,
"id": "d4f822da-45bf-4222-95fa-5ce6a912869b",
"metadata": {
"tags": []
Expand All @@ -835,13 +918,19 @@
"Lender @ addr_test1vqd3yrtjyx49uld43lvwqaf7z4k03su8gf2x4yr7syzvckgfzm4ck\n",
" TxHash TxIx Amount\n",
"--------------------------------------------------------------------------------------\n",
"78690d72c67960d4600889d7dd7da2069f14658ed6791c8838dccdd33fe3971f 1 1000000000 lovelace + TxOutDatumNone\n",
"dd3a06e118f9ccfdc6d8721779228d1730a606cf183489e679f2584b4445d883 1 1000000000 lovelace + TxOutDatumNone\n",
"\n",
"\n",
"Borrower @ addr_test1vpy4n4peh4suv0y55yptur0066j5kds8r4ncnuzm0vpzfgg0dhz6d\n",
" TxHash TxIx Amount\n",
"--------------------------------------------------------------------------------------\n",
"78690d72c67960d4600889d7dd7da2069f14658ed6791c8838dccdd33fe3971f 2 1000000000 lovelace + TxOutDatumNone\n",
"dd3a06e118f9ccfdc6d8721779228d1730a606cf183489e679f2584b4445d883 2 1000000000 lovelace + TxOutDatumNone\n",
"\n",
"\n",
"Borrower @ addr_test1vr6tytqs3x8qgewhw89m3xrz58t3tqu2hfsecw0u06lf3hg052wsv\n",
" TxHash TxIx Amount\n",
"--------------------------------------------------------------------------------------\n",
"dd3a06e118f9ccfdc6d8721779228d1730a606cf183489e679f2584b4445d883 3 1000000000 lovelace + TxOutDatumNone\n",
"\n"
]
}
Expand All @@ -855,6 +944,10 @@
"echo\n",
"echo \"Borrower @ $BORROWER_ADDR\"\n",
"cardano-cli query utxo --testnet-magic \"$CARDANO_TESTNET_MAGIC\" --address \"$BORROWER_ADDR\"\n",
"echo\n",
"echo\n",
"echo \"Borrower @ $MEDIATOR_ADDR\"\n",
"cardano-cli query utxo --testnet-magic \"$CARDANO_TESTNET_MAGIC\" --address \"$MEDIATOR_ADDR\"\n",
"echo"
]
}
Expand Down
8 changes: 4 additions & 4 deletions 01-runtime-cli/ReadMe.ipynb
Expand Up @@ -79,11 +79,11 @@
"\n",
"It also assumes that the Lender and Borrower parties have addresses, signing keys, and funds.\n",
"- Lender\n",
" - `LENDER_ADDR`: Cardano address for the lender\n",
" - `LENDER_SKEY`: location of signing key file for the lender\n",
" - [../keys/lender.address](../keys/lender.address): Cardano address for the lender\n",
" - [../keys/lender.skey](../keys/lender.skey): location of signing key file for the lender\n",
"- Borrower\n",
" - `BORROWER_ADDR`: Cardano address for the borrower\n",
" - `BORROWER_SKEY`: locatio nof signing key file for the borrower"
" - [../keys/borrower.address](../keys/borrower.address): Cardano address for the borrower\n",
" - [../keys/borrower.skey](../keys/borrower.skey): location of signing key file for the borrower"
]
},
{
Expand Down
16 changes: 8 additions & 8 deletions 02-runtime-rest/ReadMe.ipynb
Expand Up @@ -6,6 +6,7 @@
"metadata": {},
"source": [
"# Zero-Coupon Bond Using Marlowe Runtime\\'s REST API\n",
"\n",
"The zero-coupon bond example is a simple Marlowe contract where a lender provides principal to a borrower who repays it back with interest.\n",
"\n",
"In this demonsration we use Marlowe Runtime\\'s REST API, served via `marlowe-web-server`, to run this contract on Cardano\\'s `preprod` public testnet. Marlowe contracts may use either addresses or role tokens for authorization: here we use role tokens and we have Marlowe Runtime mint them.\n",
Expand Down Expand Up @@ -76,11 +77,11 @@
"\n",
"It also assumes that the Lender and Borrower parties have addresses, signing keys, and funds.\n",
"- Lender\n",
" - `LENDER_ADDR`: Cardano address for the lender\n",
" - `LENDER_SKEY`: location of signing key file for the lender\n",
" - [../keys/lender.address](../keys/lender.address): Cardano address for the lender\n",
" - [../keys/lender.skey](../keys/lender.skey): location of signing key file for the lender\n",
"- Borrower\n",
" - `BORROWER_ADDR`: Cardano address for the borrower\n",
" - `BORROWER_SKEY`: locatio nof signing key file for the borrower"
" - [../keys/borrower.address](../keys/borrower.address): Cardano address for the borrower\n",
" - [../keys/borrower.skey](../keys/borrower.skey): location of signing key file for the borrower"
]
},
{
Expand Down Expand Up @@ -370,7 +371,7 @@
}
],
"source": [
"ADA=1000000 # 1 ada = 1,000,000 lovelace\n",
"ADA=1000000 # 1 ada = 1,000,000 lovelace\n",
"PRINCIPAL=$((80 * ADA))\n",
"INTEREST=$((5 * ADA))\n",
"echo \"PRINCIPAL = $PRINCIPAL lovelace\"\n",
Expand Down Expand Up @@ -438,7 +439,6 @@
"1. Visit https://play.marlowe-finance.io/ in a web browser.\n",
"2. Select \"Open an Example\".\n",
"3. Select \"Marlowe\" or \"Blockly\" under \"Zero Coupon Bond\".\n",
"4. Edit the contract set set\n",
"4. Select \"Send to Simulator\".\n",
"5. Set the \"Loan Deadline\" to one hour into the future.\n",
"6. Set the \"Payback Deadline\" to three hours into the future.\n",
Expand Down Expand Up @@ -673,7 +673,7 @@
"\n",
"Here are the steps for checking the safety of a contract:\n",
"\n",
"1. Understand the [Marlowe Language](https://marlowe-finance.io/)\n",
"1. Understand the [Marlowe Language](https://marlowe-finance.io/).\n",
"2. Understand Cardano\\'s [Extended UTxO Model](https://docs.cardano.org/learn/eutxo-explainer).\n",
"3. Read and understand the [Marlowe Best Practices Guide](https://github.com/input-output-hk/marlowe-cardano/blob/main/marlowe/best-practices.md).\n",
"4. Read and understand the [Marlowe Security Guide](https://github.com/input-output-hk/marlowe-cardano/blob/main/marlowe/security.md).\n",
Expand Down Expand Up @@ -1536,7 +1536,7 @@
"source": [
"## Transaction 3. The borrower withdraws the principal\n",
"\n",
"The principal of 80 ada is help at Marlowe's role-payout address for the benefit of the borrower. The borrower can withdraw these funds at any time. The contract ID and role name are included in the request body for a withdrawal."
"The principal of 80 ada is held at Marlowe's role-payout address for the benefit of the borrower. The borrower can withdraw these funds at any time. The contract ID and role name are included in the request body for a withdrawal."
]
},
{
Expand Down
10 changes: 5 additions & 5 deletions 03-marlowe-cli/ReadMe.ipynb
Expand Up @@ -77,11 +77,11 @@
"\n",
"It also assumes that the Lender and Borrower parties have addresses, signing keys, and funds.\n",
"- Lender\n",
" - `LENDER_ADDR`: Cardano address for the lender\n",
" - `LENDER_SKEY`: location of signing key file for the lender\n",
" - [../keys/lender.address](../keys/lender.address): Cardano address for the lender\n",
" - [../keys/lender.skey](../keys/lender.skey): location of signing key file for the lender\n",
"- Borrower\n",
" - `BORROWER_ADDR`: Cardano address for the borrower\n",
" - `BORROWER_SKEY`: locatio nof signing key file for the borrower"
" - [../keys/borrower.address](../keys/borrower.address): Cardano address for the borrower\n",
" - [../keys/borrower.skey](../keys/borrower.skey): location of signing key file for the borrower"
]
},
{
Expand Down Expand Up @@ -621,7 +621,7 @@
"\n",
"Here are the steps for checking the safety of a contract:\n",
"\n",
"1. Understand the [Marlowe Language](https://marlowe-finance.io/)\n",
"1. Understand the [Marlowe Language](https://marlowe-finance.io/).\n",
"2. Understand Cardano\\'s [Extended UTxO Model](https://docs.cardano.org/learn/eutxo-explainer).\n",
"3. Read and understand the [Marlowe Best Practices Guide](https://github.com/input-output-hk/marlowe-cardano/blob/main/marlowe/best-practices.md).\n",
"4. Read and understand the [Marlowe Security Guide](https://github.com/input-output-hk/marlowe-cardano/blob/main/marlowe/security.md).\n",
Expand Down

0 comments on commit 85424a8

Please sign in to comment.