[examples] A very simple auction-related example.

This commit is contained in:
Alessandro Coglio 2022-08-03 23:05:27 -07:00
parent d216cc1722
commit 07154af8ec
5 changed files with 43 additions and 0 deletions

2
examples/auction/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
outputs/
build/

View File

@ -0,0 +1,8 @@
# auction.aleo
## Build Guide
To compile this Aleo program, run:
```bash
aleo build
```

View File

@ -0,0 +1,4 @@
// The program input for auction/src/main.leo
[main]
public a: u32 = 1u32;
b: u32 = 2u32;

View File

@ -0,0 +1,10 @@
{
"program": "auction.aleo",
"version": "0.0.0",
"description": "",
"development": {
"private_key": "APrivateKey1zkp5wvamYgK3WCAdpBQxZqQX8XnuN2u11Y6QprZTriVwZVc",
"address": "aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh"
},
"license": "MIT"
}

View 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;
}
}