-
Notifications
You must be signed in to change notification settings - Fork 655
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
outputs/ | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# lottery.aleo | ||
|
||
## Build Guide | ||
|
||
To compile this Aleo program, run: | ||
```bash | ||
aleo build | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// The program input for lottery/src/main.leo | ||
[main] | ||
public a: u32 = 1u32; | ||
b: u32 = 2u32; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"program": "lottery.aleo", | ||
"version": "0.0.0", | ||
"description": "", | ||
"development": { | ||
"private_key": "APrivateKey1zkpJrHD9orEuTpL8dDnSBZo6VyKWdbrk3VJfcwEv9SsQBN2", | ||
"address": "aleo1dvx603addv7c2uqj6ksm9hccaypzn0ngus4n2vygvdlhqvkcyyfqvh4zdz" | ||
}, | ||
"license": "MIT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// The 'lottery' program. | ||
program lottery.aleo { | ||
|
||
mapping num_winners: u8 => u8; | ||
|
||
record Ticket { | ||
owner: address, | ||
} | ||
|
||
transition play() -> u32 { | ||
let ticket: Ticket = Ticket { | ||
owner: self.caller, | ||
}; | ||
return ticket then finalize(); | ||
} | ||
|
||
finalize play() { | ||
// Check that the lottery has not expired. | ||
assert(block.height <= 1000); | ||
|
||
// Randomly select whether or not the ticket is a winner. | ||
assert(ChaCha::rand_bool()); | ||
|
||
// Check that the maximum number of winners have not been reached. | ||
let winners: u8 = num_winners.get_or_use(0u8); | ||
assert(winners < 5u8); | ||
num_winners.set(0u8, winners + 1u8); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
namespace: Compile | ||
expectation: Pass | ||
outputs: | ||
- - initial_ast: 2d7b208912c97c514488786ee171503bfe6d230fb6f0f35725fdcc0d217dad20 | ||
unrolled_ast: 2d7b208912c97c514488786ee171503bfe6d230fb6f0f35725fdcc0d217dad20 | ||
ssa_ast: d31261c1b1ffc59dae4f917070deae35adcb480707a00e4ce900458f962855cc | ||
flattened_ast: 57633e91a7d54fa5f5ec007863b135a0b1bca23f3016c2bc01ab8293ad2f59d4 | ||
inlined_ast: 57633e91a7d54fa5f5ec007863b135a0b1bca23f3016c2bc01ab8293ad2f59d4 | ||
dce_ast: 09659efca22ece8c63c317e0e22e1400871541e2d40a6604e073e64a7fc54153 | ||
bytecode: 268f9afb6b8472b88b0c91f927b0cd4a69c10ad4457714dbb6faddeee5405cc6 | ||
warnings: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters