mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-27 12:17:35 +03:00
[example] Simple interest calculation.
This commit is contained in:
parent
754a3ce685
commit
123aa2822c
2
examples/interest/.gitignore
vendored
Normal file
2
examples/interest/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
outputs/
|
||||||
|
build/
|
8
examples/interest/README.md
Normal file
8
examples/interest/README.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# interest.aleo
|
||||||
|
|
||||||
|
## Build Guide
|
||||||
|
|
||||||
|
To compile this Aleo program, run:
|
||||||
|
```bash
|
||||||
|
aleo build
|
||||||
|
```
|
4
examples/interest/inputs/interest.in
Normal file
4
examples/interest/inputs/interest.in
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
// The program input for interest/src/main.leo
|
||||||
|
[main]
|
||||||
|
capital: u32 = 80u32;
|
||||||
|
rate: u32 = 5u32; // 5%
|
10
examples/interest/program.json
Normal file
10
examples/interest/program.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"program": "interest.aleo",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"description": "",
|
||||||
|
"development": {
|
||||||
|
"private_key": "APrivateKey1zkp6QSDYHfL4Tr54dKXXxSwZWVpm1Ro3feYgpvAampgNmKu",
|
||||||
|
"address": "aleo1lwxu6nluvjt6hu0gurjsph23wlvyxkut59r757szma2s9mrljggsvue3n4"
|
||||||
|
},
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
8
examples/interest/src/main.leo
Normal file
8
examples/interest/src/main.leo
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// The 'interest' main function.
|
||||||
|
function main(capital: u32, public rate: u32) -> u32 {
|
||||||
|
let amount: u32 = capital;
|
||||||
|
for i:u8 in 0u8..10u8 { // accrue for 10 periods
|
||||||
|
amount += amount * rate / 100u32; // round down
|
||||||
|
}
|
||||||
|
return amount;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user