mirror of
https://github.com/AleoHQ/leo.git
synced 2024-11-24 02:42:21 +03:00
[examples] A very simple auction-related example.
This commit is contained in:
parent
d216cc1722
commit
07154af8ec
2
examples/auction/.gitignore
vendored
Normal file
2
examples/auction/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
outputs/
|
||||
build/
|
8
examples/auction/README.md
Normal file
8
examples/auction/README.md
Normal file
@ -0,0 +1,8 @@
|
||||
# auction.aleo
|
||||
|
||||
## Build Guide
|
||||
|
||||
To compile this Aleo program, run:
|
||||
```bash
|
||||
aleo build
|
||||
```
|
4
examples/auction/inputs/auction.in
Normal file
4
examples/auction/inputs/auction.in
Normal file
@ -0,0 +1,4 @@
|
||||
// The program input for auction/src/main.leo
|
||||
[main]
|
||||
public a: u32 = 1u32;
|
||||
b: u32 = 2u32;
|
10
examples/auction/program.json
Normal file
10
examples/auction/program.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"program": "auction.aleo",
|
||||
"version": "0.0.0",
|
||||
"description": "",
|
||||
"development": {
|
||||
"private_key": "APrivateKey1zkp5wvamYgK3WCAdpBQxZqQX8XnuN2u11Y6QprZTriVwZVc",
|
||||
"address": "aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
19
examples/auction/src/main.leo
Normal file
19
examples/auction/src/main.leo
Normal file
@ -0,0 +1,19 @@
|
||||
record Auction {
|
||||
owner: address,
|
||||
gates: u64,
|
||||
winning_bidder: address,
|
||||
winning_bid: u64
|
||||
}
|
||||
|
||||
function main(current: Auction, bidder: address, bid: u64) -> Auction {
|
||||
if bid > current.winning_bid {
|
||||
return Auction {
|
||||
owner: current.owner,
|
||||
gates: current.gates,
|
||||
winning_bidder: bidder,
|
||||
winning_bid: bid
|
||||
};
|
||||
} else {
|
||||
return current;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user