diff --git a/examples/interest/.gitignore b/examples/interest/.gitignore new file mode 100644 index 0000000000..b28696155d --- /dev/null +++ b/examples/interest/.gitignore @@ -0,0 +1,2 @@ +outputs/ +build/ diff --git a/examples/interest/README.md b/examples/interest/README.md new file mode 100644 index 0000000000..c9fb67bcfc --- /dev/null +++ b/examples/interest/README.md @@ -0,0 +1,8 @@ +# interest.aleo + +## Build Guide + +To compile this Aleo program, run: +```bash +aleo build +``` diff --git a/examples/interest/inputs/interest.in b/examples/interest/inputs/interest.in new file mode 100644 index 0000000000..96576291e9 --- /dev/null +++ b/examples/interest/inputs/interest.in @@ -0,0 +1,4 @@ +// The program input for interest/src/main.leo +[main] +capital: u32 = 80u32; +rate: u32 = 5u32; // 5% diff --git a/examples/interest/program.json b/examples/interest/program.json new file mode 100644 index 0000000000..90056fcb88 --- /dev/null +++ b/examples/interest/program.json @@ -0,0 +1,10 @@ +{ + "program": "interest.aleo", + "version": "0.0.0", + "description": "", + "development": { + "private_key": "APrivateKey1zkp6QSDYHfL4Tr54dKXXxSwZWVpm1Ro3feYgpvAampgNmKu", + "address": "aleo1lwxu6nluvjt6hu0gurjsph23wlvyxkut59r757szma2s9mrljggsvue3n4" + }, + "license": "MIT" +} diff --git a/examples/interest/src/main.leo b/examples/interest/src/main.leo new file mode 100644 index 0000000000..3ca31a7e7a --- /dev/null +++ b/examples/interest/src/main.leo @@ -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; +}