diff --git a/auction/.env b/auction/.env index 253455a..1c9c1f6 100644 --- a/auction/.env +++ b/auction/.env @@ -1,4 +1,5 @@ -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2GUmKbVsuc1NSj28pa1WTQuZaK5f1DQJAT6vPcHyWokG +ENDPOINT=https://api.explorer.provable.com/v1 diff --git a/auction/README.md b/auction/README.md index d9a3963..ece40ce 100644 --- a/auction/README.md +++ b/auction/README.md @@ -81,7 +81,7 @@ Swap in the private key and address of the first bidder to `.env`. ```bash echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH " > .env ``` @@ -100,7 +100,7 @@ Swap in the private key of the second bidder to `.env`. ```bash echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh " > .env ``` @@ -119,7 +119,7 @@ Swap in the private key of the auctioneer to `.env`. ```bash echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2GUmKbVsuc1NSj28pa1WTQuZaK5f1DQJAT6vPcHyWokG " > .env ``` diff --git a/auction/build/README.md b/auction/build/README.md new file mode 100644 index 0000000..0762a9c --- /dev/null +++ b/auction/build/README.md @@ -0,0 +1,13 @@ +# auction.aleo + +## Build Guide + +To compile this Aleo program, run: +```bash +snarkvm build +``` + +To execute this Aleo program, run: +```bash +snarkvm run hello +``` diff --git a/auction/build/main.aleo b/auction/build/main.aleo index 23f1140..95b6c87 100644 --- a/auction/build/main.aleo +++ b/auction/build/main.aleo @@ -6,7 +6,6 @@ record Bid: amount as u64.private; is_winner as boolean.private; - function place_bid: input r0 as address.private; input r1 as u64.private; @@ -14,7 +13,6 @@ function place_bid: cast aleo1ashyu96tjwe63u0gtnnv8z5lhapdu4l5pjsl2kha7fv7hvz2eqxs5dz0rg r0 r1 false into r2 as Bid.record; output r2 as Bid.record; - function resolve: input r0 as Bid.record; input r1 as Bid.record; @@ -27,7 +25,6 @@ function resolve: cast r3 r4 r5 r6 into r7 as Bid.record; output r7 as Bid.record; - function finish: input r0 as Bid.record; assert.eq self.caller aleo1ashyu96tjwe63u0gtnnv8z5lhapdu4l5pjsl2kha7fv7hvz2eqxs5dz0rg; diff --git a/auction/build/program.json b/auction/build/program.json index 86302fc..3679991 100644 --- a/auction/build/program.json +++ b/auction/build/program.json @@ -1,6 +1,6 @@ { - "program": "auction.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" + "program": "auction.aleo", + "version": "0.0.0", + "description": "", + "license": "MIT" } diff --git a/auction/run.sh b/auction/run.sh index 903c0b8..3864e1b 100755 --- a/auction/run.sh +++ b/auction/run.sh @@ -44,8 +44,9 @@ Let's take the role of the first bidder - we'll swap in the private key and addr We're going to run the transition function "place_bid", slotting in the first bidder's public address and the amount that is being bid. The inputs are the user's public address and the amount being bid. echo ' -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH +ENDPOINT=https://api.explorer.provable.com/v1 ' > .env leo run place_bid aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px 10u64 @@ -53,8 +54,9 @@ leo run place_bid aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9p # Swap in the private key of the first bidder to .env. echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH +ENDPOINT=https://api.explorer.provable.com/v1 " > .env # Have the first bidder place a bid of 10. @@ -78,8 +80,9 @@ echo " Now we're going to place another bid as the second bidder, so let's switch our keys to the second bidder and run the same transition function, this time with the second bidder's keys, public address, and different amount. echo ' -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh +ENDPOINT=https://api.explorer.provable.com/v1 ' > .env leo run place_bid aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t 90u64 @@ -87,8 +90,9 @@ leo run place_bid aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4 # Swap in the private key of the second bidder to .env. echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh +ENDPOINT=https://api.explorer.provable.com/v1 " > .env # Have the second bidder place a bid of 90. @@ -112,8 +116,9 @@ echo " Now, let's take the role of the auctioneer, so we can determine which bid wins. Let's swap our keys to the auctioneer and run the resolve command on the output of the two bids from before. The resolve command takes the two output records from the bids as inputs and compares them to determine which bid wins. echo ' -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2GUmKbVsuc1NSj28pa1WTQuZaK5f1DQJAT6vPcHyWokG +ENDPOINT=https://api.explorer.provable.com/v1 ' > .env leo run resolve '{ @@ -133,8 +138,9 @@ leo run resolve '{ # Swaps in the private key of the auctioneer to .env. echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2GUmKbVsuc1NSj28pa1WTQuZaK5f1DQJAT6vPcHyWokG +ENDPOINT=https://api.explorer.provable.com/v1 " > .env # Have the auctioneer select the winning bid. diff --git a/basic_bank/.env b/basic_bank/.env index 6a4fe03..87abfe7 100644 --- a/basic_bank/.env +++ b/basic_bank/.env @@ -1,4 +1,5 @@ -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH +ENDPOINT=https://api.explorer.provable.com/v1 diff --git a/basic_bank/README.md b/basic_bank/README.md index 335cabb..a9ef1a2 100644 --- a/basic_bank/README.md +++ b/basic_bank/README.md @@ -71,7 +71,7 @@ Let's make some bank transactions. We'll take the role of the bank and issue 100 ```bash echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH " > .env @@ -84,7 +84,7 @@ Now, let's have the user deposit 50 of their tokens with the bank. We'll take th ```bash echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh " > .env @@ -109,7 +109,7 @@ Now, let's have the bank withdraw all tokens after 15 periods. Let's switch to t ```bash echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH " > .env diff --git a/basic_bank/build/README.md b/basic_bank/build/README.md new file mode 100644 index 0000000..e78c4b4 --- /dev/null +++ b/basic_bank/build/README.md @@ -0,0 +1,13 @@ +# basic_bank.aleo + +## Build Guide + +To compile this Aleo program, run: +```bash +snarkvm build +``` + +To execute this Aleo program, run: +```bash +snarkvm run hello +``` diff --git a/basic_bank/build/main.aleo b/basic_bank/build/main.aleo index 73965d8..3403b7e 100644 --- a/basic_bank/build/main.aleo +++ b/basic_bank/build/main.aleo @@ -4,10 +4,9 @@ record Token: owner as address.private; amount as u64.private; - mapping balances: - key as field.public; - value as u64.public; + key as field.public; + value as u64.public; function issue: input r0 as address.private; @@ -16,8 +15,6 @@ function issue: cast r0 r1 into r2 as Token.record; output r2 as Token.record; - - function deposit: input r0 as Token.record; input r1 as u64.private; @@ -35,8 +32,6 @@ finalize deposit: add r2 r1 into r3; set r3 into balances[r0]; - - closure calculate_interest: input r0 as u64; input r1 as u64; @@ -543,8 +538,6 @@ closure calculate_interest: ternary r498 r501 r497 into r502; output r502 as u64; - - function withdraw: input r0 as address.private; input r1 as u64.private; @@ -564,4 +557,3 @@ finalize withdraw: get.or_use balances[r0] 0u64 into r2; sub r2 r1 into r3; set r3 into balances[r0]; - diff --git a/basic_bank/build/program.json b/basic_bank/build/program.json index 13c1bc0..521ee8f 100644 --- a/basic_bank/build/program.json +++ b/basic_bank/build/program.json @@ -1,6 +1,6 @@ { - "program": "basic_bank.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT" + "program": "basic_bank.aleo", + "version": "0.0.0", + "description": "", + "license": "MIT" } diff --git a/basic_bank/run.sh b/basic_bank/run.sh index 8bc6398..7e0e9c1 100755 --- a/basic_bank/run.sh +++ b/basic_bank/run.sh @@ -22,8 +22,9 @@ echo " 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. echo ' -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH +ENDPOINT=https://api.explorer.provable.com/v1 ' > .env leo run issue aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t 100u64 @@ -31,8 +32,9 @@ leo run issue aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t 10 # Swap in the private key of the bank to .env. echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH +ENDPOINT=https://api.explorer.provable.com/v1 " > .env # Have the bank issue 100 tokens to the user. @@ -83,8 +85,9 @@ echo " 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. echo ' -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh +ENDPOINT=https://api.explorer.provable.com/v1 ' > .env leo run deposit '{ @@ -96,8 +99,9 @@ leo run deposit '{ # Swap in the private key of the user to .env. echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh +ENDPOINT=https://api.explorer.provable.com/v1 " > .env # Have the user deposit 50 tokens into the bank. @@ -199,8 +203,9 @@ echo " 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. echo ' -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH +ENDPOINT=https://api.explorer.provable.com/v1 ' > .env leo run withdraw aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t 50u64 1234u64 15u64 @@ -208,8 +213,9 @@ leo run withdraw aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t " # Swap in the private key of the bank to .env. echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH +ENDPOINT=https://api.explorer.provable.com/v1 " > .env # Have the bank withdraw all of the user's tokens with compound interest over 15 periods at 12.34%. diff --git a/battleship/.env b/battleship/.env index 6a4fe03..87abfe7 100644 --- a/battleship/.env +++ b/battleship/.env @@ -1,4 +1,5 @@ -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH +ENDPOINT=https://api.explorer.provable.com/v1 diff --git a/battleship/README.md b/battleship/README.md index e098446..e5dbbe9 100644 --- a/battleship/README.md +++ b/battleship/README.md @@ -69,7 +69,7 @@ With Player 1's private key, they initialize the board with the placement of 4 s ```bash echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH " > .env @@ -156,7 +156,7 @@ We switch our .env to Player 2's private key and similarly run initialize_board ```bash echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh " > .env @@ -248,7 +248,7 @@ We switch the .env back to Player 1, and we run the transition function play. ```bash echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH " > .env @@ -304,7 +304,7 @@ We switch the .env back to Player 2, and we run the transition function play. ```bash echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh " > .env @@ -365,7 +365,7 @@ We switch the .env back to Player 1, and we run the transition function play. ```bash echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH " > .env @@ -433,7 +433,7 @@ We switch the .env back to Player 2, and we run the transition function play. ```bash echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh " > .env diff --git a/battleship/board/build/main.aleo b/battleship/board/build/main.aleo index fac2e70..341f8ee 100644 --- a/battleship/board/build/main.aleo +++ b/battleship/board/build/main.aleo @@ -9,14 +9,12 @@ record board_state: player_2 as address.private; game_started as boolean.private; - function new_board_state: input r0 as u64.private; input r1 as address.private; cast self.caller 0u64 0u64 r0 self.caller r1 false into r2 as board_state.record; output r2 as board_state.record; - function start_board: input r0 as board_state.record; not r0.game_started into r1; @@ -24,7 +22,6 @@ function start_board: cast r0.owner r0.hits_and_misses r0.played_tiles r0.ships r0.player_1 r0.player_2 true into r2 as board_state.record; output r2 as board_state.record; - function update_played_tiles: input r0 as board_state.record; input r1 as u64.private; @@ -37,7 +34,6 @@ function update_played_tiles: cast r0.owner r0.hits_and_misses r5 r0.ships r0.player_1 r0.player_2 r0.game_started into r6 as board_state.record; output r6 as board_state.record; - function update_hits_and_misses: input r0 as board_state.record; input r1 as u64.private; diff --git a/battleship/build/README.md b/battleship/build/README.md new file mode 100644 index 0000000..806514a --- /dev/null +++ b/battleship/build/README.md @@ -0,0 +1,13 @@ +# battleship.aleo + +## Build Guide + +To compile this Aleo program, run: +```bash +snarkvm build +``` + +To execute this Aleo program, run: +```bash +snarkvm run hello +``` diff --git a/battleship/build/imports/board.aleo b/battleship/build/imports/board.aleo index fac2e70..341f8ee 100644 --- a/battleship/build/imports/board.aleo +++ b/battleship/build/imports/board.aleo @@ -9,14 +9,12 @@ record board_state: player_2 as address.private; game_started as boolean.private; - function new_board_state: input r0 as u64.private; input r1 as address.private; cast self.caller 0u64 0u64 r0 self.caller r1 false into r2 as board_state.record; output r2 as board_state.record; - function start_board: input r0 as board_state.record; not r0.game_started into r1; @@ -24,7 +22,6 @@ function start_board: cast r0.owner r0.hits_and_misses r0.played_tiles r0.ships r0.player_1 r0.player_2 true into r2 as board_state.record; output r2 as board_state.record; - function update_played_tiles: input r0 as board_state.record; input r1 as u64.private; @@ -37,7 +34,6 @@ function update_played_tiles: cast r0.owner r0.hits_and_misses r5 r0.ships r0.player_1 r0.player_2 r0.game_started into r6 as board_state.record; output r6 as board_state.record; - function update_hits_and_misses: input r0 as board_state.record; input r1 as u64.private; diff --git a/battleship/build/imports/move.aleo b/battleship/build/imports/move.aleo index ed5247d..5dcf7b8 100644 --- a/battleship/build/imports/move.aleo +++ b/battleship/build/imports/move.aleo @@ -7,7 +7,6 @@ record move: player_2 as address.private; prev_hit_or_miss as u64.private; - function create_move: input r0 as move.record; input r1 as u64.private; @@ -17,7 +16,6 @@ function create_move: cast r4 r1 r0.player_2 r0.player_1 r2 into r5 as move.record; output r5 as move.record; - function start_game: input r0 as address.private; cast r0 0u64 self.caller r0 0u64 into r1 as move.record; diff --git a/battleship/build/imports/verify.aleo b/battleship/build/imports/verify.aleo index 804dcf2..25cc0cb 100644 --- a/battleship/build/imports/verify.aleo +++ b/battleship/build/imports/verify.aleo @@ -1,7 +1,5 @@ program verify.aleo; - - closure bitcount: input r0 as u64; div r0 2u64 into r1; @@ -19,7 +17,6 @@ closure bitcount: rem r12 255u64 into r13; output r13 as u64; - closure adjacency_check: input r0 as u64; input r1 as u64; @@ -31,7 +28,6 @@ closure adjacency_check: is.eq r6 0u64 into r7; output r7 as boolean; - closure horizontal_check: input r0 as u64; input r1 as u64; @@ -44,7 +40,6 @@ closure horizontal_check: is.eq r7 0u64 into r8; output r8 as boolean; - function validate_ship: input r0 as u64.private; input r1 as u64.private; @@ -59,7 +54,6 @@ function validate_ship: or r7 r8 into r9; output r9 as boolean.private; - function create_board: input r0 as u64.private; input r1 as u64.private; diff --git a/battleship/build/main.aleo b/battleship/build/main.aleo index 5fe36f9..3492ca5 100644 --- a/battleship/build/main.aleo +++ b/battleship/build/main.aleo @@ -3,9 +3,6 @@ import move.aleo; import verify.aleo; program battleship.aleo; - - - function initialize_board: input r0 as u64.private; input r1 as u64.private; @@ -24,7 +21,6 @@ function initialize_board: call board.aleo/new_board_state r9 r4 into r10; output r10 as board.aleo/board_state.record; - function offer_battleship: input r0 as board.aleo/board_state.record; call board.aleo/start_board r0 into r1; @@ -32,7 +28,6 @@ function offer_battleship: output r1 as board.aleo/board_state.record; output r2 as move.aleo/move.record; - function start_battleship: input r0 as board.aleo/board_state.record; input r1 as move.aleo/move.record; @@ -43,7 +38,6 @@ function start_battleship: output r2 as board.aleo/board_state.record; output r3 as move.aleo/move.record; - function play: input r0 as board.aleo/board_state.record; input r1 as move.aleo/move.record; diff --git a/battleship/build/program.json b/battleship/build/program.json index fe5a3d5..f51fc0c 100644 --- a/battleship/build/program.json +++ b/battleship/build/program.json @@ -1,23 +1,6 @@ { - "program": "battleship.aleo", - "version": "0.0.0", - "description": "", - "license": "MIT", - "dependencies" : [ - { - "name": "board.aleo", - "location": "local", - "path": "board" - }, - { - "name": "move.aleo", - "location": "local", - "path": "move" - }, - { - "name": "verify.aleo", - "location": "local", - "path": "verify" - } - ] + "program": "battleship.aleo", + "version": "0.0.0", + "description": "", + "license": "MIT" } diff --git a/battleship/leo.lock b/battleship/leo.lock index 601531f..404012a 100644 --- a/battleship/leo.lock +++ b/battleship/leo.lock @@ -1,20 +1,20 @@ [[package]] name = "board.aleo" location = "local" -path = "/Users/pranav/work/Aleo/workshop/battleship/board" -checksum = "da94274230d0c0c3deb96d80e07ad9db8bbf53264286c14cc3231b7a8b7ef380" +path = "/Users/michaelbenfield/Code/workshop/battleship/board" +checksum = "3437097857bd7bc5811f51dbe3d50979b90c63aabe69cd7b43e8d778335c8f82" dependencies = [] [[package]] name = "move.aleo" location = "local" -path = "/Users/pranav/work/Aleo/workshop/battleship/move" -checksum = "7d9fef5fe083eb24376e63935855e4ec709c17fb5ee46a0bb4594b0f9ef8eb08" +path = "/Users/michaelbenfield/Code/workshop/battleship/move" +checksum = "cad6c149312ad8c0e7dbe0e099d53de8c45c4b0205bb07c96b6245b1504bc53a" dependencies = [] [[package]] name = "verify.aleo" location = "local" -path = "/Users/pranav/work/Aleo/workshop/battleship/verify" -checksum = "2c2035ebd70500b7e5a9a6198bed1a1163cd1ddfd09128db8f4c16cf23ad2c62" +path = "/Users/michaelbenfield/Code/workshop/battleship/verify" +checksum = "e08b9a05eff5a6c74ff0e6aa955e1a51389e3433f7b43d68a48328c8051a703f" dependencies = [] diff --git a/battleship/move/build/main.aleo b/battleship/move/build/main.aleo index ed5247d..5dcf7b8 100644 --- a/battleship/move/build/main.aleo +++ b/battleship/move/build/main.aleo @@ -7,7 +7,6 @@ record move: player_2 as address.private; prev_hit_or_miss as u64.private; - function create_move: input r0 as move.record; input r1 as u64.private; @@ -17,7 +16,6 @@ function create_move: cast r4 r1 r0.player_2 r0.player_1 r2 into r5 as move.record; output r5 as move.record; - function start_game: input r0 as address.private; cast r0 0u64 self.caller r0 0u64 into r1 as move.record; diff --git a/battleship/run.sh b/battleship/run.sh index 6a7ae92..0e0d93c 100755 --- a/battleship/run.sh +++ b/battleship/run.sh @@ -26,14 +26,16 @@ echo " ############################################################################### echo ' -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH +ENDPOINT=https://api.explorer.provable.com/v1 ' > .env " echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH +ENDPOINT=https://api.explorer.provable.com/v1 " > .env echo " @@ -92,16 +94,18 @@ echo " We switch our .env to Player 2's private key and similarly run initialize_board to create a new and different board for player two. echo ' -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh +ENDPOINT=https://api.explorer.provable.com/v1 ' > .env leo run initialize_board 31u64 2207646875648u64 224u64 9042383626829824u64 aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px " echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh +ENDPOINT=https://api.explorer.provable.com/v1 " > .env leo run initialize_board 31u64 2207646875648u64 224u64 9042383626829824u64 aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px @@ -162,8 +166,9 @@ echo " We switch the .env back to Player 1, and we run the transition function play. echo ' -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH +ENDPOINT=https://api.explorer.provable.com/v1 ' > .env leo run play '{ @@ -186,8 +191,9 @@ leo run play '{ " echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH +ENDPOINT=https://api.explorer.provable.com/v1 " > .env leo run play "{ @@ -218,8 +224,9 @@ echo " We switch the .env back to Player 2, and we run the transition function play. echo ' -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh +ENDPOINT=https://api.explorer.provable.com/v1 ' > .env leo run play '{ @@ -242,8 +249,9 @@ leo run play '{ " echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh +ENDPOINT=https://api.explorer.provable.com/v1 " > .env leo run play "{ @@ -274,8 +282,9 @@ echo " We switch the .env back to Player 1, and we run the transition function play. echo ' -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH +ENDPOINT=https://api.explorer.provable.com/v1 ' > .env leo run play '{ @@ -298,8 +307,9 @@ leo run play '{ " echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH +ENDPOINT=https://api.explorer.provable.com/v1 " > .env leo run play "{ @@ -330,8 +340,9 @@ echo " We switch the .env back to Player 2, and we run the transition function play. echo ' -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh +ENDPOINT=https://api.explorer.provable.com/v1 ' > .env leo run play '{ @@ -354,8 +365,9 @@ leo run play '{ " echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh +ENDPOINT=https://api.explorer.provable.com/v1 " > .env leo run play "{ @@ -377,6 +389,7 @@ leo run play "{ }" 4u64 echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH +ENDPOINT=https://api.explorer.provable.com/v1 " > .env diff --git a/battleship/verify/build/main.aleo b/battleship/verify/build/main.aleo index 804dcf2..25cc0cb 100644 --- a/battleship/verify/build/main.aleo +++ b/battleship/verify/build/main.aleo @@ -1,7 +1,5 @@ program verify.aleo; - - closure bitcount: input r0 as u64; div r0 2u64 into r1; @@ -19,7 +17,6 @@ closure bitcount: rem r12 255u64 into r13; output r13 as u64; - closure adjacency_check: input r0 as u64; input r1 as u64; @@ -31,7 +28,6 @@ closure adjacency_check: is.eq r6 0u64 into r7; output r7 as boolean; - closure horizontal_check: input r0 as u64; input r1 as u64; @@ -44,7 +40,6 @@ closure horizontal_check: is.eq r7 0u64 into r8; output r8 as boolean; - function validate_ship: input r0 as u64.private; input r1 as u64.private; @@ -59,7 +54,6 @@ function validate_ship: or r7 r8 into r9; output r9 as boolean.private; - function create_board: input r0 as u64.private; input r1 as u64.private; diff --git a/tictactoe/.env b/tictactoe/.env index c7836c7..87abfe7 100644 --- a/tictactoe/.env +++ b/tictactoe/.env @@ -1,2 +1,5 @@ -NETWORK=mainnet + +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH +ENDPOINT=https://api.explorer.provable.com/v1 + diff --git a/tictactoe/build/README.md b/tictactoe/build/README.md new file mode 100644 index 0000000..a42b90f --- /dev/null +++ b/tictactoe/build/README.md @@ -0,0 +1,13 @@ +# tictactoe.aleo + +## Build Guide + +To compile this Aleo program, run: +```bash +snarkvm build +``` + +To execute this Aleo program, run: +```bash +snarkvm run hello +``` diff --git a/tictactoe/build/main.aleo b/tictactoe/build/main.aleo index f557eef..097ef55 100644 --- a/tictactoe/build/main.aleo +++ b/tictactoe/build/main.aleo @@ -10,7 +10,6 @@ struct Board: r2 as Row; r3 as Row; - function new: cast 0u8 0u8 0u8 into r0 as Row; cast 0u8 0u8 0u8 into r1 as Row; @@ -18,7 +17,6 @@ function new: cast r0 r1 r2 into r3 as Board; output r3 as Board.private; - closure check_for_win: input r0 as Board; input r1 as u8; @@ -71,7 +69,6 @@ closure check_for_win: or r42 r47 into r48; output r48 as boolean; - function make_move: input r0 as u8.private; input r1 as u8.private; @@ -184,54 +181,36 @@ function make_move: cast r100 r101 r102 into r105 as Row; cast r103 r104 r105 into r106 as Board; call check_for_win r106 1u8 into r107; - call check_for_win r106 2u8 into r108; - not r107 into r109; - and r109 r108 into r110; + not r107 into r108; + call check_for_win r106 2u8 into r109; + and r108 r109 into r110; ternary r110 r106.r1.c1 r106.r1.c1 into r111; - not r107 into r112; - and r112 r108 into r113; - ternary r113 r106.r1.c2 r106.r1.c2 into r114; - not r107 into r115; - and r115 r108 into r116; - ternary r116 r106.r1.c3 r106.r1.c3 into r117; - cast r111 r114 r117 into r118 as Row; - not r107 into r119; - and r119 r108 into r120; - ternary r120 r106.r2.c1 r106.r2.c1 into r121; - not r107 into r122; - and r122 r108 into r123; - ternary r123 r106.r2.c2 r106.r2.c2 into r124; - not r107 into r125; - and r125 r108 into r126; - ternary r126 r106.r2.c3 r106.r2.c3 into r127; - cast r121 r124 r127 into r128 as Row; - not r107 into r129; - and r129 r108 into r130; - ternary r130 r106.r3.c1 r106.r3.c1 into r131; - not r107 into r132; - and r132 r108 into r133; - ternary r133 r106.r3.c2 r106.r3.c2 into r134; - not r107 into r135; - and r135 r108 into r136; - ternary r136 r106.r3.c3 r106.r3.c3 into r137; - cast r131 r134 r137 into r138 as Row; - cast r118 r128 r138 into r139 as Board; - not r107 into r140; - and r140 r108 into r141; - ternary r141 2u8 0u8 into r142; - ternary r107 r106.r1.c1 r139.r1.c1 into r143; - ternary r107 r106.r1.c2 r139.r1.c2 into r144; - ternary r107 r106.r1.c3 r139.r1.c3 into r145; - cast r143 r144 r145 into r146 as Row; - ternary r107 r106.r2.c1 r139.r2.c1 into r147; - ternary r107 r106.r2.c2 r139.r2.c2 into r148; - ternary r107 r106.r2.c3 r139.r2.c3 into r149; - cast r147 r148 r149 into r150 as Row; - ternary r107 r106.r3.c1 r139.r3.c1 into r151; - ternary r107 r106.r3.c2 r139.r3.c2 into r152; - ternary r107 r106.r3.c3 r139.r3.c3 into r153; - cast r151 r152 r153 into r154 as Row; - cast r146 r150 r154 into r155 as Board; - ternary r107 1u8 r142 into r156; - output r155 as Board.private; - output r156 as u8.private; + ternary r110 r106.r1.c2 r106.r1.c2 into r112; + ternary r110 r106.r1.c3 r106.r1.c3 into r113; + cast r111 r112 r113 into r114 as Row; + ternary r110 r106.r2.c1 r106.r2.c1 into r115; + ternary r110 r106.r2.c2 r106.r2.c2 into r116; + ternary r110 r106.r2.c3 r106.r2.c3 into r117; + cast r115 r116 r117 into r118 as Row; + ternary r110 r106.r3.c1 r106.r3.c1 into r119; + ternary r110 r106.r3.c2 r106.r3.c2 into r120; + ternary r110 r106.r3.c3 r106.r3.c3 into r121; + cast r119 r120 r121 into r122 as Row; + cast r114 r118 r122 into r123 as Board; + ternary r110 2u8 0u8 into r124; + ternary r107 r106.r1.c1 r123.r1.c1 into r125; + ternary r107 r106.r1.c2 r123.r1.c2 into r126; + ternary r107 r106.r1.c3 r123.r1.c3 into r127; + cast r125 r126 r127 into r128 as Row; + ternary r107 r106.r2.c1 r123.r2.c1 into r129; + ternary r107 r106.r2.c2 r123.r2.c2 into r130; + ternary r107 r106.r2.c3 r123.r2.c3 into r131; + cast r129 r130 r131 into r132 as Row; + ternary r107 r106.r3.c1 r123.r3.c1 into r133; + ternary r107 r106.r3.c2 r123.r3.c2 into r134; + ternary r107 r106.r3.c3 r123.r3.c3 into r135; + cast r133 r134 r135 into r136 as Row; + cast r128 r132 r136 into r137 as Board; + ternary r107 1u8 r124 into r138; + output r137 as Board.private; + output r138 as u8.private; diff --git a/tictactoe/run.sh b/tictactoe/run.sh index 93a0443..e8f7e33 100755 --- a/tictactoe/run.sh +++ b/tictactoe/run.sh @@ -22,6 +22,12 @@ Create a new game. leo run new " +echo ' +NETWORK=testnet +PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH +ENDPOINT=https://api.explorer.provable.com/v1 +' > .env + leo run new echo " diff --git a/token/.env b/token/.env index d4e429c..58bb095 100644 --- a/token/.env +++ b/token/.env @@ -1,4 +1,5 @@ -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh +ENDPOINT=https://api.explorer.provable.com/v1 diff --git a/token/README.md b/token/README.md index bf277ec..5996a5e 100644 --- a/token/README.md +++ b/token/README.md @@ -46,7 +46,7 @@ Let's play Alice. Swap in her private key and publicly mint 100 tokens. ```bash echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH " > .env @@ -61,7 +61,7 @@ Now let's privately mint 100 tokens for Bob. Switch to Bob's private key and pri ```bash echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh " > .env @@ -76,7 +76,7 @@ Let's publicly transfer 10 tokens from Alice to Bob. Swap the private key back t ```bash echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH " > .env @@ -91,7 +91,7 @@ Let's privately transfer 20 tokens from Bob to Alice. Switch to Bob's private ke ```bash echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh " > .env @@ -110,7 +110,7 @@ Let's convert 30 of Alice's public tokens into 30 private tokens for Bob. Switch ```bash echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH " > .env @@ -125,7 +125,7 @@ Let's convert 40 of Bob's private tokens into 40 public tokens for Alice. Switch ```bash echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh " > .env diff --git a/token/build/README.md b/token/build/README.md new file mode 100644 index 0000000..d77d2f2 --- /dev/null +++ b/token/build/README.md @@ -0,0 +1,13 @@ +# token.aleo + +## Build Guide + +To compile this Aleo program, run: +```bash +snarkvm build +``` + +To execute this Aleo program, run: +```bash +snarkvm run hello +``` diff --git a/token/build/main.aleo b/token/build/main.aleo index f7711f8..fd940a0 100644 --- a/token/build/main.aleo +++ b/token/build/main.aleo @@ -4,11 +4,9 @@ record token: owner as address.private; amount as u64.private; - mapping account: - key as address.public; - value as u64.public; - + key as address.public; + value as u64.public; function mint_public: input r0 as address.public; @@ -23,16 +21,12 @@ finalize mint_public: add r2 r1 into r3; set r3 into account[r0]; - - function mint_private: input r0 as address.private; input r1 as u64.private; cast r0 r1 into r2 as token.record; output r2 as token.record; - - function transfer_public: input r0 as address.public; input r1 as u64.public; @@ -50,8 +44,6 @@ finalize transfer_public: add r5 r2 into r6; set r6 into account[r1]; - - function transfer_private: input r0 as token.record; input r1 as address.private; @@ -62,8 +54,6 @@ function transfer_private: output r4 as token.record; output r5 as token.record; - - function transfer_private_to_public: input r0 as token.record; input r1 as address.public; @@ -81,9 +71,6 @@ finalize transfer_private_to_public: add r2 r1 into r3; set r3 into account[r0]; - - - function transfer_public_to_private: input r0 as address.public; input r1 as u64.public; @@ -98,4 +85,3 @@ finalize transfer_public_to_private: get.or_use account[r0] 0u64 into r2; sub r2 r1 into r3; set r3 into account[r0]; - diff --git a/token/run.sh b/token/run.sh index 549a576..b023df5 100755 --- a/token/run.sh +++ b/token/run.sh @@ -22,16 +22,18 @@ echo " Let's play Alice. Swap in her private key and publicly mint 100 tokens. echo ' -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH +ENDPOINT=https://api.explorer.provable.com/v1 ' > .env leo run mint_public aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px 100u64 " echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH +ENDPOINT=https://api.explorer.provable.com/v1 " > .env leo run mint_public aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px 100u64 @@ -68,16 +70,18 @@ echo " Now let's privately mint 100 tokens for Bob. Switch to Bob's private key and privately mint 100 tokens for Bob. echo ' -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh +ENDPOINT=https://api.explorer.provable.com/v1 ' > .env leo run mint_private aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t 100u64 " echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh +ENDPOINT=https://api.explorer.provable.com/v1 " > .env leo run mint_private aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t 100u64 @@ -114,16 +118,18 @@ echo " Let's publicly transfer 10 tokens from Alice to Bob. Swap the private key back to Alice and call the public transfer transition. echo ' -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH +ENDPOINT=https://api.explorer.provable.com/v1 ' > .env leo run transfer_public aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t 10u64 " echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH +ENDPOINT=https://api.explorer.provable.com/v1 " > .env leo run transfer_public aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t 10u64 @@ -160,8 +166,9 @@ echo " Let's privately transfer 20 tokens from Bob to Alice. Switch to Bob's private key and call the private transfer transition. echo ' -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh +ENDPOINT=https://api.explorer.provable.com/v1 ' > .env leo run transfer_private '{ @@ -172,8 +179,9 @@ leo run transfer_private '{ " echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh +ENDPOINT=https://api.explorer.provable.com/v1 " > .env leo run transfer_private "{ @@ -214,16 +222,18 @@ echo " Let's convert 30 of Alice's public tokens into 30 private tokens for Bob. Switch the private key back to Alice. echo ' -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH +ENDPOINT=https://api.explorer.provable.com/v1 ' > .env leo run transfer_public_to_private aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t 30u64 " echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH +ENDPOINT=https://api.explorer.provable.com/v1 " > .env leo run transfer_public_to_private aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t 30u64 @@ -261,8 +271,9 @@ echo " Let's convert 40 of Bob's private tokens into 40 public tokens for Alice. Switch the private key back to Bob. echo ' -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh +ENDPOINT=https://api.explorer.provable.com/v1 ' > .env leo run transfer_private_to_public '{ @@ -273,8 +284,9 @@ leo run transfer_private_to_public '{ " echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh +ENDPOINT=https://api.explorer.provable.com/v1 " > .env leo run transfer_private_to_public "{ diff --git a/token/src/main.leo b/token/src/main.leo index 7746348..592cc86 100644 --- a/token/src/main.leo +++ b/token/src/main.leo @@ -92,10 +92,10 @@ program token.aleo { // Output the sender's change record. // Increment the token amount publicly for the token receiver. - return (remaining, finalize_transfer_private_to_public(receiver, amount)); + return (remaining, finalize_transfer_priv_to_pub(receiver, amount)); } - async function finalize_transfer_private_to_public(public receiver: address, public amount: u64) { + async function finalize_transfer_priv_to_pub(public receiver: address, public amount: u64) { // Increments `account[receiver]` by `amount`. // If `account[receiver]` does not exist, it will be created. // If `account[receiver] + amount` overflows, `transfer_private_to_public` is reverted. @@ -114,10 +114,10 @@ program token.aleo { // Output the receiver's record. // Decrement the token amount of the caller publicly. - return (transferred, finalize_transfer_public_to_private(self.caller, amount)); + return (transferred, finalize_transfer_pub_to_priv(self.caller, amount)); } - async function finalize_transfer_public_to_private(public sender: address, public amount: u64) { + async function finalize_transfer_pub_to_priv(public sender: address, public amount: u64) { // Decrements `account[sender]` by `amount`. // If `account[sender]` does not exist, it will be created. // If `account[sender] - amount` underflows, `transfer_public_to_private` is reverted. diff --git a/vote/.env b/vote/.env index 253455a..1c9c1f6 100644 --- a/vote/.env +++ b/vote/.env @@ -1,4 +1,5 @@ -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2GUmKbVsuc1NSj28pa1WTQuZaK5f1DQJAT6vPcHyWokG +ENDPOINT=https://api.explorer.provable.com/v1 diff --git a/vote/README.md b/vote/README.md index 1196705..edc2369 100644 --- a/vote/README.md +++ b/vote/README.md @@ -72,7 +72,7 @@ Let's propose a new ballot. Take on the role of the proposer and run the propose ```bash echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH " > .env @@ -91,7 +91,7 @@ Let's create a new private ticket to make a vote. Take on the role of voter 1 an ```bash echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh " > .env @@ -116,7 +116,7 @@ Let's create a new private ticket for voter 2. Take on the role of voter 1 and r ```bash echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2GUmKbVsuc1NSj28pa1WTQuZaK5f1DQJAT6vPcHyWokG " > .env diff --git a/vote/build/README.md b/vote/build/README.md new file mode 100644 index 0000000..965be15 --- /dev/null +++ b/vote/build/README.md @@ -0,0 +1,13 @@ +# vote.aleo + +## Build Guide + +To compile this Aleo program, run: +```bash +snarkvm build +``` + +To execute this Aleo program, run: +```bash +snarkvm run hello +``` diff --git a/vote/build/main.aleo b/vote/build/main.aleo index 4da3939..5b16db3 100644 --- a/vote/build/main.aleo +++ b/vote/build/main.aleo @@ -14,26 +14,21 @@ record Ticket: owner as address.private; pid as field.private; - mapping proposals: - key as field.public; - value as ProposalInfo.public; - + key as field.public; + value as ProposalInfo.public; mapping tickets: - key as field.public; - value as u64.public; - + key as field.public; + value as u64.public; mapping agree_votes: - key as field.public; - value as u64.public; - + key as field.public; + value as u64.public; mapping disagree_votes: - key as field.public; - value as u64.public; - + key as field.public; + value as u64.public; function propose: input r0 as ProposalInfo.public; @@ -48,9 +43,6 @@ finalize propose: input r0 as field.public; set 0u64 into tickets[r0]; - - - function new_ticket: input r0 as field.public; input r1 as address.public; @@ -65,9 +57,6 @@ finalize new_ticket: add r1 1u64 into r2; set r2 into tickets[r0]; - - - function agree: input r0 as Ticket.record; async agree r0.pid into r1; @@ -79,9 +68,6 @@ finalize agree: add r1 1u64 into r2; set r2 into agree_votes[r0]; - - - function disagree: input r0 as Ticket.record; async disagree r0.pid into r1; @@ -92,4 +78,3 @@ finalize disagree: get.or_use disagree_votes[r0] 0u64 into r1; add r1 1u64 into r2; set r2 into disagree_votes[r0]; - diff --git a/vote/run.sh b/vote/run.sh index 18920cd..e36032e 100755 --- a/vote/run.sh +++ b/vote/run.sh @@ -26,8 +26,9 @@ echo " Let's propose a new ballot. Take on the role of the proposer and run the propose transition function. We've provided the necessary information as inputs to the propose function. echo ' -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH +ENDPOINT=https://api.explorer.provable.com/v1 ' > .env leo run propose '{ @@ -39,8 +40,9 @@ leo run propose '{ # swaps in the private key of the proposer to .env echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH +ENDPOINT=https://api.explorer.provable.com/v1 " > .env # runs the propose transition function with proposal info as the input @@ -72,8 +74,9 @@ echo " Let's create a new private ticket to make a vote. 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. echo ' -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh +ENDPOINT=https://api.explorer.provable.com/v1 ' > .env leo run new_ticket 2264670486490520844857553240576860973319410481267184439818180411609250173817field aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t @@ -81,8 +84,9 @@ leo run new_ticket 2264670486490520844857553240576860973319410481267184439818180 # Swap in the private key of voter 1 to .env. echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh +ENDPOINT=https://api.explorer.provable.com/v1 " > .env # Runs the new_ticket transition function with unique id and voter address as inputs. @@ -140,8 +144,9 @@ echo " 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. echo ' -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2GUmKbVsuc1NSj28pa1WTQuZaK5f1DQJAT6vPcHyWokG +ENDPOINT=https://api.explorer.provable.com/v1 ' > .env leo run new_ticket 2158670485494560943857353240576760973319410481267184429818180411607250143681field aleo1ashyu96tjwe63u0gtnnv8z5lhapdu4l5pjsl2kha7fv7hvz2eqxs5dz0rg @@ -149,8 +154,9 @@ leo run new_ticket 2158670485494560943857353240576760973319410481267184429818180 # Swap in the private key of voter 2 to .env. echo " -NETWORK=testnet3 +NETWORK=testnet PRIVATE_KEY=APrivateKey1zkp2GUmKbVsuc1NSj28pa1WTQuZaK5f1DQJAT6vPcHyWokG +ENDPOINT=https://api.explorer.provable.com/v1 " > .env # Run the new_ticket transition function with unique id and voter address as inputs.