Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion auction/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

NETWORK=testnet3
NETWORK=testnet
PRIVATE_KEY=APrivateKey1zkp2GUmKbVsuc1NSj28pa1WTQuZaK5f1DQJAT6vPcHyWokG
ENDPOINT=https://api.explorer.provable.com/v1

6 changes: 3 additions & 3 deletions auction/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -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
```
Expand All @@ -119,7 +119,7 @@ Swap in the private key of the auctioneer to `.env`.

```bash
echo "
NETWORK=testnet3
NETWORK=testnet
PRIVATE_KEY=APrivateKey1zkp2GUmKbVsuc1NSj28pa1WTQuZaK5f1DQJAT6vPcHyWokG
" > .env
```
Expand Down
13 changes: 13 additions & 0 deletions auction/build/README.md
Original file line number Diff line number Diff line change
@@ -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
```
3 changes: 0 additions & 3 deletions auction/build/main.aleo
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ record Bid:
amount as u64.private;
is_winner as boolean.private;


function place_bid:
input r0 as address.private;
input r1 as u64.private;
assert.eq self.caller r0;
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;
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions auction/build/program.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"program": "auction.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT"
"program": "auction.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT"
}
18 changes: 12 additions & 6 deletions auction/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,19 @@ 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
"

# 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.
Expand All @@ -78,17 +80,19 @@ 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
"

# 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.
Expand All @@ -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 '{
Expand All @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion basic_bank/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

NETWORK=testnet3
NETWORK=testnet
PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH
ENDPOINT=https://api.explorer.provable.com/v1

6 changes: 3 additions & 3 deletions basic_bank/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down
13 changes: 13 additions & 0 deletions basic_bank/build/README.md
Original file line number Diff line number Diff line change
@@ -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
```
12 changes: 2 additions & 10 deletions basic_bank/build/main.aleo
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -564,4 +557,3 @@ finalize withdraw:
get.or_use balances[r0] 0u64 into r2;
sub r2 r1 into r3;
set r3 into balances[r0];

8 changes: 4 additions & 4 deletions basic_bank/build/program.json
Original file line number Diff line number Diff line change
@@ -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"
}
18 changes: 12 additions & 6 deletions basic_bank/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,19 @@ 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
"

# 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.
Expand Down Expand Up @@ -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 '{
Expand All @@ -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.
Expand Down Expand Up @@ -199,17 +203,19 @@ 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

"
# 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%.
Expand Down
3 changes: 2 additions & 1 deletion battleship/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

NETWORK=testnet3
NETWORK=testnet
PRIVATE_KEY=APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH
ENDPOINT=https://api.explorer.provable.com/v1

12 changes: 6 additions & 6 deletions battleship/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
Loading