Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update examples to leo v1.9.0 #39

Merged
merged 7 commits into from
Jul 22, 2023
Merged
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
4 changes: 4 additions & 0 deletions auction/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkp5wvamYgK3WCAdpBQxZqQX8XnuN2u11Y6QprZTriVwZVc

4 changes: 3 additions & 1 deletion auction/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
outputs/
build/
*.avm
*.prover
*.verifier
11 changes: 4 additions & 7 deletions auction/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,14 @@ Leo provides users with a command line interface for compiling and running Leo p
Users may either specify input values via the command line or provide an input file in `inputs/`.

### Configuring Accounts
The `program.json` file contains a private key and address.
The `.env` file contains a private key.
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` and `address` fields in `program.json` to the appropriate values.
When executing programs as different parties, be sure to set the `PRIVATE_KEY` field in `.env` to the appropriate values.
See `./run.sh` for an example of how to run the program as different parties.


The [Aleo SDK](https://github.com/AleoHQ/leo/tree/testnet3) provides a command line interface for generating new accounts.
To generate a new account, run
```
leo account new
```
The [Aleo SDK](https://github.com/AleoHQ/leo/tree/testnet3) provides an interface for generating new accounts.
To generate a new account, navigate to [aleo.tools](https://aleo.tools).


### Providing inputs via the command line.
Expand Down
35 changes: 35 additions & 0 deletions auction/build/main.aleo
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
program auction.aleo;

record Bid:
owner as address.private;
bidder as address.private;
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 aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh 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;
assert.eq self.caller aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh;
gte r0.amount r1.amount into r2;
ternary r2 r0.owner r1.owner into r3;
ternary r2 r0.bidder r1.bidder into r4;
ternary r2 r0.amount r1.amount into r5;
ternary r2 r0.is_winner r1.is_winner into r6;
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 aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh;
cast r0.bidder r0.bidder r0.amount true into r1 as Bid.record;
output r1 as Bid.record;
6 changes: 6 additions & 0 deletions auction/build/program.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"program": "auction.aleo",
"version": "0.0.0",
"description": "",
"license": "MIT"
}
4 changes: 0 additions & 4 deletions auction/program.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@
"program": "auction.aleo",
"version": "0.0.0",
"description": "",
"development": {
"private_key": "APrivateKey1zkp5wvamYgK3WCAdpBQxZqQX8XnuN2u11Y6QprZTriVwZVc",
"address": "aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh"
},
"license": "MIT"
}
59 changes: 20 additions & 39 deletions auction/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,11 @@ echo "
######## ########
###############################################################################
"
# Swap in the private key and address of the first bidder to program.json.
echo "{
\"program\": \"auction.aleo\",
\"version\": \"0.0.0\",
\"description\": \"\",
\"development\": {
\"private_key\": \"APrivateKey1zkpG9Af9z5Ha4ejVyMCqVFXRKknSm8L1ELEwcc4htk9YhVK\",
\"address\": \"aleo1yzlta2q5h8t0fqe0v6dyh9mtv4aggd53fgzr068jvplqhvqsnvzq7pj2ke\"
},
\"license\": \"MIT\"
}" > program.json
# Swap in the private key and address of the first bidder to .env.
echo "
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpG9Af9z5Ha4ejVyMCqVFXRKknSm8L1ELEwcc4htk9YhVK
" > .env

# Have the first bidder place a bid of 10.
echo "
Expand All @@ -61,20 +55,13 @@ echo "
######## ########
###############################################################################
"
leo run place_bid aleo1yzlta2q5h8t0fqe0v6dyh9mtv4aggd53fgzr068jvplqhvqsnvzq7pj2ke 10u64

# Swap in the private key and address of the second bidder to program.json.
echo "{
\"program\": \"auction.aleo\",
\"version\": \"0.0.0\",
\"description\": \"\",
\"development\": {
\"private_key\": \"APrivateKey1zkpAFshdsj2EqQzXh5zHceDapFWVCwR6wMCJFfkLYRKupug\",
\"address\": \"aleo1esqchvevwn7n5p84e735w4dtwt2hdtu4dpguwgwy94tsxm2p7qpqmlrta4\"
},
\"license\": \"MIT\"
}" > program.json
leo run place_bid aleo1yzlta2q5h8t0fqe0v6dyh9mtv4aggd53fgzr068jvplqhvqsnvzq7pj2ke 10u64 || exit

# Swap in the private key and address of the second bidder to .env.
echo "
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpAFshdsj2EqQzXh5zHceDapFWVCwR6wMCJFfkLYRKupug
" > .env

# Have the second bidder place a bid of 90.
echo "
Expand All @@ -90,19 +77,13 @@ echo "
######## ########
###############################################################################
"
leo run place_bid aleo1esqchvevwn7n5p84e735w4dtwt2hdtu4dpguwgwy94tsxm2p7qpqmlrta4 90u64

# Swap in the private key and address of the auctioneer to program.json.
echo "{
\"program\": \"auction.aleo\",
\"version\": \"0.0.0\",
\"description\": \"\",
\"development\": {
\"private_key\": \"APrivateKey1zkp5wvamYgK3WCAdpBQxZqQX8XnuN2u11Y6QprZTriVwZVc\",
\"address\": \"aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh\"
},
\"license\": \"MIT\"
}" > program.json
leo run place_bid aleo1esqchvevwn7n5p84e735w4dtwt2hdtu4dpguwgwy94tsxm2p7qpqmlrta4 90u64 || exit

# Swap in the private key and address of the auctioneer to .env.
echo "
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkp5wvamYgK3WCAdpBQxZqQX8XnuN2u11Y6QprZTriVwZVc
" > .env

# Have the auctioneer select the winning bid.
echo "
Expand Down Expand Up @@ -130,7 +111,7 @@ leo run resolve "{
amount: 90u64.private,
is_winner: false.private,
_nonce: 5952811863753971450641238938606857357746712138665944763541786901326522216736group.public
}"
}" || exit

# Have the auctioneer finish the auction.
echo "
Expand All @@ -152,7 +133,7 @@ leo run finish "{
amount: 90u64.private,
is_winner: false.private,
_nonce: 5952811863753971450641238938606857357746712138665944763541786901326522216736group.public
}"
}" || exit



Expand Down
4 changes: 4 additions & 0 deletions basic_bank/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpHtqVWT6fSHgUMNxsuVf7eaR6id2cj7TieKY1Z8CP5rCD

4 changes: 3 additions & 1 deletion basic_bank/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
outputs/
build/
*.avm
*.prover
*.verifier
13 changes: 4 additions & 9 deletions basic_bank/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,14 @@ Leo provides users with a command line interface for compiling and running Leo p
Users may either specify input values via the command line or provide an input file in `inputs/`.

### Configuring Accounts
The `program.json` file contains a private key and address.
The `.env` file contains a private key.
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` and `address` fields in `program.json` to the appropriate values.


When executing programs as different parties, be sure to set the `PRIVATE_KEY` field in `.env` to the appropriate values.
See `./run.sh` for an example of how to run the program as different parties.


The [Aleo SDK](https://github.com/AleoHQ/leo/tree/testnet3) provides a command line interface for generating new accounts.
To generate a new account, run
```
leo account new
```
The [Aleo SDK](https://github.com/AleoHQ/leo/tree/testnet3) provides an interface for generating new accounts.
To generate a new account, navigate to [aleo.tools](https://aleo.tools).


### Providing inputs via the command line.
Expand Down
Loading