diff --git a/documentation/leo/10_basic_bank.md b/documentation/leo/10_basic_bank.md index be8dfd8ad..62f556910 100644 --- a/documentation/leo/10_basic_bank.md +++ b/documentation/leo/10_basic_bank.md @@ -60,7 +60,7 @@ private_key: APrivateKey1zkp75cpr5NNQpVWc5mfsD9Uf2wg6XvHknf82iwB636q3rtc address: aleo1zeklp6dd8e764spe74xez6f8w27dlua3w7hl4z2uln03re52egpsv46ngg ``` -Let's make some bank transactions. We'll take the role of the bank and issue 100 tokens to the user. We swap the private key into `.env` and run the issue transition function. The inputs are simply the recipient of the issuance and the amount. +Let's make some bank transactions. We'll take the role of the bank and issue 100 tokens to the user. We swap the private key into `.env` and run the `issue` transition function. The inputs are simply the recipient of the issuance and the amount. ```bash echo " @@ -73,7 +73,7 @@ leo run issue aleo1zeklp6dd8e764spe74xez6f8w27dlua3w7hl4z2uln03re52egpsv46ngg 10 ## Deposit Tokens -Now, let's have the user deposit 50 of their tokens with the bank. We'll take the role of the user and call the deposit function, having the user use the output record that was issued to them by the bank. The inputs are the output record from the issue transition and the amount the user wishes to deposit. +Now, let's have the user deposit 50 of their tokens with the bank. We'll take the role of the user and call the deposit function, having the user use the output record that was issued to them by the bank. The inputs are the output record from the `issue` transition and the amount the user wishes to deposit. ```bash echo " @@ -88,7 +88,7 @@ leo run deposit "{ }" 50u64 ``` -You'll see that the output contains a new private record belonging to the user with 50 credits, and a finalize deposit function taking the arguments (bank address, amount) that will update a public mapping with 50 credits. This information is queryable on-chain. +You'll see that the output contains a new private record belonging to the user with 50 credits, and a finalize `deposit` function taking the arguments (bank address, amount) that will update a public mapping with 50 credits. This information is queryable on-chain. ## Wait @@ -98,7 +98,7 @@ You can run the calculation yourself, it comes out to 266 tokens accrued using t ## Withdraw Tokens -Now, let's have the bank withdraw all tokens after 15 periods. Let's switch to the bank role, and call the withdraw transition function. The inputs are the recipient's address, amount, rate, and periods. +Now, let's have the bank withdraw all tokens after 15 periods. Let's switch to the bank role, and call the `withdraw` transition function. The inputs are the recipient's address, amount, rate, and periods. ```bash echo " @@ -109,4 +109,4 @@ PRIVATE_KEY=APrivateKey1zkpHtqVWT6fSHgUMNxsuVf7eaR6id2cj7TieKY1Z8CP5rCD leo run withdraw aleo1zeklp6dd8e764spe74xez6f8w27dlua3w7hl4z2uln03re52egpsv46ngg 50u64 1234u64 15u64 ``` -You'll see here the withdrawal function creates a new private record for the user containing all 266 withdrawn tokens, and then calls the finalize withdraw function with arguments (address, amount), which will update the public balance of the bank back to 0. The public mapping will be queryable on-chain. \ No newline at end of file +You'll see here the withdrawal function creates a new private record for the user containing all 266 withdrawn tokens, and then calls the finalize `withdraw` function with arguments (address, amount), which will update the public balance of the bank back to 0. The public mapping will be queryable on-chain. \ No newline at end of file diff --git a/documentation/leo/12_vote.md b/documentation/leo/12_vote.md index 87380781a..a3b0dd541 100644 --- a/documentation/leo/12_vote.md +++ b/documentation/leo/12_vote.md @@ -27,88 +27,29 @@ cd vote The `.env` file contains a private key and address. This is the account that will be used to sign transactions and is checked for record ownership. When executing programs as different parties, be sure to set the `private_key` field in `.env` to the appropriate value. You can check out how we've set things up in `./run.sh` for a full example of how to run the program as different parties. - ## Walkthrough +* [Functions](#functions) * [Create a Proposal](#step0) * [Voter 1 makes a vote](#step1) * [Voter 2 makes a vote](#step2) * [How votes are tallied](#step3) - - - - - ## Functions ### Propose Anyone can issue a new proposal publicly by calling `propose` function. -Run `propose`: - -``` -leo run propose -``` - -Output sample: - -``` - { - owner: aleo1kkk52quhnxgn2nfrcd9jqk7c9x27c23f2wvw7fyzcze56yahvcgszgttu2.private, - id: 2805252584833208809872967597325381727971256629741137995614832105537063464740field.private, - info: { - title: 2077160157502449938194577302446444field.private, - content: 1452374294790018907888397545906607852827800436field.private, - proposer: aleo1kkk52quhnxgn2nfrcd9jqk7c9x27c23f2wvw7fyzcze56yahvcgszgttu2.private - }, - _nonce: 1639660347839832220966145410710039205878572956621820215177036061076060242021group.public -} -``` - ### Create Ticket Proposers can create new tickets for proposed proposals. -Ticket is a record with `owner` and `pid`, -it can be used to vote for the specific proposal - `pid`, -and can only be used(voted) by the ticket `owner`. - -Run `new_ticket`: - -``` -leo run new_ticket -``` - -Output sample: - -``` -{ - owner: aleo1kkk52quhnxgn2nfrcd9jqk7c9x27c23f2wvw7fyzcze56yahvcgszgttu2.private, - pid: 2264670486490520844857553240576860973319410481267184439818180411609250173817field.private, - _nonce: 1637267040221574073903539416642641433705357302885235345311606754421919550724group.public -} -``` +Ticket is a record with `owner` and `pid`, it can be used to vote for the specific proposal - `pid`, and can only be used(voted) by the ticket `owner`. ### Vote -A ticket owner can use their ticket record to vote `agree` / `disagree` with the specific proposal - `pid`. - -Since the ticket record can be used as an input privately, the voter's privacy is protected. - -Run `agree`: - -``` -leo run agree -``` - -Run `disagree`: - -``` -leo run disagree -``` - +A ticket owner can use their ticket record to vote `agree` / `disagree` with the specific proposal - `pid`. Since the ticket record can be used as an input privately, the voter's privacy is protected. ## Create a Proposal @@ -171,7 +112,7 @@ leo run agree "{ ## Voter 2 makes a vote -Let's create a new private ticket for voter 2. Take on the role of voter 1 and run the new_ticket transition. The inputs take a unique ticket ID and the voter's public address. +Let's create a new private ticket for voter 2. Take on the role of voter 1 and run the `new_ticket` transition. The inputs take a unique ticket ID and the voter's public address. ```bash echo " diff --git a/documentation/leo/13_token.md b/documentation/leo/13_token.md index 881f67830..425426a14 100644 --- a/documentation/leo/13_token.md +++ b/documentation/leo/13_token.md @@ -52,7 +52,7 @@ PRIVATE_KEY=APrivateKey1zkp1w8PTxrRgGfAtfKUSq43iQyVbdQHfhGbiNPEg2LVSEXR leo run mint_public aleo13ssze66adjjkt795z9u5wpq8h6kn0y2657726h4h3e3wfnez4vqsm3008q 100u64 ``` -You can see the output of the finalize function of mint_public, which takes the arguments Alice's address and the amount of tokens to mint publicly. This information is shown on-chain and can be queried on a network. +You can see the output of the finalize function of `mint_public`, which takes the arguments Alice's address and the amount of tokens to mint publicly. This information is shown on-chain and can be queried on a network. ## Private Mint @@ -82,7 +82,7 @@ PRIVATE_KEY=APrivateKey1zkp1w8PTxrRgGfAtfKUSq43iQyVbdQHfhGbiNPEg2LVSEXR leo run transfer_public aleo17vy26rpdhqx4598y5gp7nvaa9rk7tnvl6ufhvvf4calsrrqdaqyshdsf5z 10u64 ``` -Again, we see the arguments used for the finzalize function of transfer_public - Alice's address, Bob's address, and the amount to transfer. The public mapping will be queryable on-chain. +Again, we see the arguments used for the finzalize function of `transfer_public` - Alice's address, Bob's address, and the amount to transfer. The public mapping will be queryable on-chain. ![](./images/workshop-aleo-credits-pubtrans.png) @@ -103,7 +103,7 @@ leo run transfer_private "{ }" aleo13ssze66adjjkt795z9u5wpq8h6kn0y2657726h4h3e3wfnez4vqsm3008q 20u64 ``` -The output of transfer_private is a record owned by Bob less the 20 tokens he privately transferred to Alice, and a record owned by Alice with the 20 tokens Bob transferred to Alice. +The output of `transfer_private` is a record owned by Bob less the 20 tokens he privately transferred to Alice, and a record owned by Alice with the 20 tokens Bob transferred to Alice. ![](./images/workshop-aleo-credits-privtrans.png) @@ -120,7 +120,7 @@ PRIVATE_KEY=APrivateKey1zkp1w8PTxrRgGfAtfKUSq43iQyVbdQHfhGbiNPEg2LVSEXR leo run transfer_public_to_private aleo17vy26rpdhqx4598y5gp7nvaa9rk7tnvl6ufhvvf4calsrrqdaqyshdsf5z 30u64 ``` -When calling transfer_public_to_private, we see the finalize function with the arguments to modify Alice's public token mapping (address, amount), and a private record created that's owned by Bob and contains 110 tokens. +When calling `transfer_public_to_private`, we see the finalize function with the arguments to modify Alice's public token mapping (address, amount), and a private record created that's owned by Bob and contains 110 tokens. ![](./images/workshop-aleo-credits-pubprivtrans.png) @@ -141,6 +141,6 @@ leo run transfer_private_to_public "{ }" aleo13ssze66adjjkt795z9u5wpq8h6kn0y2657726h4h3e3wfnez4vqsm3008q 40u64 ``` -When we call transfer_private_to_public, we take Bob's private record that contains 110 tokens, and outputs a record owned by Bob with 70 tokens, and calls the finalize function under transfer_private_to_public with Alice's address and 40 tokens as arguments. This changes the public mapping under Alice's address to contain 100 public tokens. Again, public mappings are queryable on-chain. +When we call `transfer_private_to_public`, we take Bob's private record that contains 110 tokens, and outputs a record owned by Bob with 70 tokens, and calls the finalize function under `transfer_private_to_public` with Alice's address and 40 tokens as arguments. This changes the public mapping under Alice's address to contain 100 public tokens. Again, public mappings are queryable on-chain. ![](./images/workshop-aleo-credits-privpubtrans.png) \ No newline at end of file diff --git a/documentation/leo/14_battleship.md b/documentation/leo/14_battleship.md index 4dcfdd70b..0c66376be 100644 --- a/documentation/leo/14_battleship.md +++ b/documentation/leo/14_battleship.md @@ -46,7 +46,6 @@ cd battleship The `.env` file contains a private key and address. This is the account that will be used to sign transactions and is checked for record ownership. When executing programs as different parties, be sure to set the `private_key` field in `.env` to the appropriate value. You can check out how we've set things up in `./run.sh` for a full example of how to run the program as different parties. - ## 1. Initializing the Players In order to play battleship, there must be two players with two boards. Players will be represented by their Aleo address. @@ -482,6 +481,7 @@ leo run play "{ ``` ## 10. Who Wins? + Play continues back and forth between Player 1 and Player 2. When one player has a total of 14 flipped bits in their `hits_and_misses` field on their `board_state.record`, they have won the game. ## ZK Battleship Privacy