Skip to content

Commit

Permalink
workshop auction additional comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Chen committed Oct 10, 2023
1 parent 80ac6ac commit 531d291
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions auction/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,23 @@ Let's start an auction!
echo "
Let's take the role of bidder 1 - we'll swap in the private key and address of the first bidder to .env.
We're going to run the transition function "place_bid", slotting in bidder 1's public address and the amount that is being bid.
We're going to run the transition function "place_bid", slotting in bidder 1'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
PRIVATE_KEY=APrivateKey1zkpG9Af9z5Ha4ejVyMCqVFXRKknSm8L1ELEwcc4htk9YhVK
' > .env
leo run place_bid aleo1yzlta2q5h8t0fqe0v6dyh9mtv4aggd53fgzr068jvplqhvqsnvzq7pj2ke 10u64 || exit
"

# swaps in the private key of bidder 1 to .env
echo "
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpG9Af9z5Ha4ejVyMCqVFXRKknSm8L1ELEwcc4htk9YhVK
" > .env

# runs the place_bid transition with inputs (user address, amount)
leo run place_bid aleo1yzlta2q5h8t0fqe0v6dyh9mtv4aggd53fgzr068jvplqhvqsnvzq7pj2ke 10u64 || exit

echo "
Expand All @@ -73,14 +80,21 @@ echo "
echo "
Now we're going to place another bid as bidder 2, so let's switch our keys to bidder 2 and run the same transition function, this time with bidder 2's keys, public address, and different amount.
echo '
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpAFshdsj2EqQzXh5zHceDapFWVCwR6wMCJFfkLYRKupug
' > .env
leo run place_bid aleo1esqchvevwn7n5p84e735w4dtwt2hdtu4dpguwgwy94tsxm2p7qpqmlrta4 90u64 || exit
"

# swaps in the private key of bidder 2 to .env
echo "
NETWORK=testnet3
PRIVATE_KEY=APrivateKey1zkpAFshdsj2EqQzXh5zHceDapFWVCwR6wMCJFfkLYRKupug
" > .env

# runs the place_bid transition with inputs (user address, amount)
leo run place_bid aleo1esqchvevwn7n5p84e735w4dtwt2hdtu4dpguwgwy94tsxm2p7qpqmlrta4 90u64 || exit

echo "
Expand All @@ -98,7 +112,12 @@ echo "
"

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.
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
PRIVATE_KEY=APrivateKey1zkp5wvamYgK3WCAdpBQxZqQX8XnuN2u11Y6QprZTriVwZVc
' > .env
leo run resolve '{
owner: aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh.private,
Expand All @@ -115,11 +134,13 @@ leo run resolve '{
}' || exit
"

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

# runs the resolve transition with inputs (two bid output records)
leo run resolve "{
owner: aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh.private,
bidder: aleo1yzlta2q5h8t0fqe0v6dyh9mtv4aggd53fgzr068jvplqhvqsnvzq7pj2ke.private,
Expand Down Expand Up @@ -149,7 +170,7 @@ echo "
"

echo "
Keeping the key environment the same since we're still the auctioneer, let's finalize the auction and label the winning output as the winner.
Keeping the key environment the same since we're still the auctioneer, let's finalize the auction and label the winning output as the winner. The finish transition takes the winning output bid as the input and marks it as such.
leo run finish '{
owner: aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh.private,
Expand All @@ -160,6 +181,7 @@ leo run finish '{
}' || exit
"

# runs the finish transition with the winning bid as the input
leo run finish "{
owner: aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh.private,
bidder: aleo1esqchvevwn7n5p84e735w4dtwt2hdtu4dpguwgwy94tsxm2p7qpqmlrta4.private,
Expand All @@ -181,6 +203,3 @@ echo "
######## ########
###############################################################################
"



0 comments on commit 531d291

Please sign in to comment.