Repository navigation
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
Β·164 lines (146 loc) Β· 8.04 KB
/
Copy pathrun.sh
File metadata and controls
executable file
Β·164 lines (146 loc) Β· 8.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/bash
# First check that Leo is installed.
if ! command -v leo &> /dev/null
then
echo "leo is not installed."
exit
fi
# The private key and address of the first bidder.
# Swap these into program.json, when running transactions as the first bidder.
# "private_key": "APrivateKey1zkpG9Af9z5Ha4ejVyMCqVFXRKknSm8L1ELEwcc4htk9YhVK"
# "address": aleo1yzlta2q5h8t0fqe0v6dyh9mtv4aggd53fgzr068jvplqhvqsnvzq7pj2ke
# The private key and address of the second bidder.
# Swap these into program.json, when running transactions as the second bidder.
# "private_key": "APrivateKey1zkpAFshdsj2EqQzXh5zHceDapFWVCwR6wMCJFfkLYRKupug"
# "address": aleo1esqchvevwn7n5p84e735w4dtwt2hdtu4dpguwgwy94tsxm2p7qpqmlrta4
# The private key and address of the auctioneer.
# Swap these into program.json, when running transactions as the auctioneer.
# "private_key": "APrivateKey1zkp5wvamYgK3WCAdpBQxZqQX8XnuN2u11Y6QprZTriVwZVc",
# "address": "aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh"
echo "
###############################################################################
######## ########
######## STEP 0: Initialize a new 2-party auction ########
######## ########
######## ------------------------------- ########
######## | OPEN | A | B | ########
######## ------------------------------- ########
######## | Bid | | | ########
######## ------------------------------- ########
######## ########
###############################################################################
"
# 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
# Have the first bidder place a bid of 10.
echo "
###############################################################################
######## ########
######## STEP 1: The first bidder places a bid of 10 ########
######## ########
######## ------------------------------- ########
######## | OPEN | A | B | ########
######## ------------------------------- ########
######## | Bid | 10 | | ########
######## ------------------------------- ########
######## ########
###############################################################################
"
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
# Have the second bidder place a bid of 90.
echo "
###############################################################################
######## ########
######## STEP 2: The second bidder places a bid of 90 ########
######## ########
######## ------------------------------- ########
######## | OPEN | A | B | ########
######## ------------------------------- ########
######## | Bid | 10 | 90 | ########
######## ------------------------------- ########
######## ########
###############################################################################
"
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
# Have the auctioneer select the winning bid.
echo "
###############################################################################
######## ########
######## STEP 3: The auctioneer selects the winning bidder ########
######## ########
######## ------------------------------- ########
######## | OPEN | A | β B β | ########
######## ------------------------------- ########
######## | Bid | 10 | β 90 β | ########
######## ------------------------------- ########
######## ########
###############################################################################
"
leo run resolve "{
owner: aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh.private,
gates: 0u64.private,
bidder: aleo1yzlta2q5h8t0fqe0v6dyh9mtv4aggd53fgzr068jvplqhvqsnvzq7pj2ke.private,
amount: 10u64.private,
is_winner: false.private,
_nonce: 4668394794828730542675887906815309351994017139223602571716627453741502624516group.public
}" "{
owner: aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh.private,
gates: 0u64.private,
bidder: aleo1esqchvevwn7n5p84e735w4dtwt2hdtu4dpguwgwy94tsxm2p7qpqmlrta4.private,
amount: 90u64.private,
is_winner: false.private,
_nonce: 5952811863753971450641238938606857357746712138665944763541786901326522216736group.public
}"
# Have the auctioneer finish the auction.
echo "
###############################################################################
######## ########
######## STEP 3: The auctioneer completes the auction. ########
######## ########
######## ------------------------------- ########
######## | CLOSE | A | β B β | ########
######## ------------------------------- ########
######## | Bid | 10 | β 90 β | ########
######## ------------------------------- ########
######## ########
###############################################################################
"
leo run finish "{
owner: aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh.private,
gates: 0u64.private,
bidder: aleo1esqchvevwn7n5p84e735w4dtwt2hdtu4dpguwgwy94tsxm2p7qpqmlrta4.private,
amount: 90u64.private,
is_winner: false.private,
_nonce: 5952811863753971450641238938606857357746712138665944763541786901326522216736group.public
}"