diff --git a/documentation/leo/10_basic_bank.md b/documentation/leo/10_basic_bank.md index 371ca0bf5..576219ee0 100644 --- a/documentation/leo/10_basic_bank.md +++ b/documentation/leo/10_basic_bank.md @@ -16,7 +16,7 @@ Note that the program can be easily extended to include additional features such ## Bugs -You may have already guessed that this program has a few bugs. We list some of them below: +You may have already guessed that this program has a few bugs. We list some of them below: - `withdraw` can only be invoked by the bank. A malicious bank could lock users' tokens by not invoking `withdraw`. - `withdraw` fails if the sum of the interest and principal is greater than the user's balance. - Users can increase their principal by depositing tokens multiple times, including immediately before withdrawal. @@ -42,7 +42,7 @@ Follow the [Leo Installation Instructions](https://developer.aleo.org/leo/instal This basic bank program can be run using the following bash script. Locally, it will execute Leo program functions to issue, deposit, and withdraw tokens between a bank and a user. ```bash -cd basic_bank +cd leo/examples/basic_bank ./run.sh ``` @@ -79,6 +79,14 @@ PRIVATE_KEY=APrivateKey1zkpHtqVWT6fSHgUMNxsuVf7eaR6id2cj7TieKY1Z8CP5rCD leo run issue aleo1zeklp6dd8e764spe74xez6f8w27dlua3w7hl4z2uln03re52egpsv46ngg 100u64 ``` +Output +```bash + • { + owner: aleo1zeklp6dd8e764spe74xez6f8w27dlua3w7hl4z2uln03re52egpsv46ngg.private, + amount: 100u64.private, + _nonce: 5747158428808897699391969939084459370750993398871840192272007071865455893612group.public +} +``` ## Deposit Tokens @@ -96,14 +104,30 @@ leo run deposit "{ _nonce: 4668394794828730542675887906815309351994017139223602571716627453741502624516group.public }" 50u64 ``` +Output +```bash + • { + owner: aleo1zeklp6dd8e764spe74xez6f8w27dlua3w7hl4z2uln03re52egpsv46ngg.private, + amount: 50u64.private, + _nonce: 832449386206374072274231152033740843999312028336559467119808470542606777523group.public +} + • { + program_id: basic_bank.aleo, + function_name: deposit, + arguments: [ + 1197470102489602745811042362685620817855019264965533852603090875444599354527field, + 50u64 + ] +} +``` -You'll see that the output contains a new private record belonging to the user with 50 credits, and a `Future` indicating code to be run on-chain and its associated inputs. +You'll see that the output contains a new private record belonging to the user with 50 credits, and a `Future` indicating code to be run on-chain and its associated inputs. ## Wait With the 50 token deposit, let's say 15 periods of time pass with compounding interest at a rate of 12.34% on the principal amount. -You can run the calculation yourself, it comes out to 266 tokens accrued using those numbers. +You can run the calculation yourself, it comes out to 266 tokens accrued using those numbers. ## Withdraw Tokens @@ -117,7 +141,22 @@ PRIVATE_KEY=APrivateKey1zkpHtqVWT6fSHgUMNxsuVf7eaR6id2cj7TieKY1Z8CP5rCD leo run withdraw aleo1zeklp6dd8e764spe74xez6f8w27dlua3w7hl4z2uln03re52egpsv46ngg 50u64 1234u64 15u64 ``` - +Output +```bash + • { + owner: aleo1zeklp6dd8e764spe74xez6f8w27dlua3w7hl4z2uln03re52egpsv46ngg.private, + amount: 266u64.private, + _nonce: 7051804730047578560256662070932795007350207323461845976313826737097831996144group.public +} + • { + program_id: basic_bank.aleo, + function_name: withdraw, + arguments: [ + 1197470102489602745811042362685620817855019264965533852603090875444599354527field, + 50u64 + ] +} +``` You'll see here the withdrawal function creates a new private record for the user containing all 266 withdrawn tokens, and then outputs a `Future` which will be run on-chain. ```