Skip to content

Commit 7a67710

Browse files
authored
Merge pull request #445 from Elexy101/basic_bank
Update 10_basic_bank.md
2 parents ca689ac + f186105 commit 7a67710

File tree

1 file changed

+44
-5
lines changed

1 file changed

+44
-5
lines changed

documentation/leo/10_basic_bank.md

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Note that the program can be easily extended to include additional features such
1616

1717
## Bugs
1818

19-
You may have already guessed that this program has a few bugs. We list some of them below:
19+
You may have already guessed that this program has a few bugs. We list some of them below:
2020
- `withdraw` can only be invoked by the bank. A malicious bank could lock users' tokens by not invoking `withdraw`.
2121
- `withdraw` fails if the sum of the interest and principal is greater than the user's balance.
2222
- 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
4242
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.
4343

4444
```bash
45-
cd basic_bank
45+
cd leo/examples/basic_bank
4646
./run.sh
4747
```
4848

@@ -79,6 +79,14 @@ PRIVATE_KEY=APrivateKey1zkpHtqVWT6fSHgUMNxsuVf7eaR6id2cj7TieKY1Z8CP5rCD
7979

8080
leo run issue aleo1zeklp6dd8e764spe74xez6f8w27dlua3w7hl4z2uln03re52egpsv46ngg 100u64
8181
```
82+
Output
83+
```bash
84+
• {
85+
owner: aleo1zeklp6dd8e764spe74xez6f8w27dlua3w7hl4z2uln03re52egpsv46ngg.private,
86+
amount: 100u64.private,
87+
_nonce: 5747158428808897699391969939084459370750993398871840192272007071865455893612group.public
88+
}
89+
```
8290

8391
## <a id="deposit"></a> Deposit Tokens
8492

@@ -96,14 +104,30 @@ leo run deposit "{
96104
_nonce: 4668394794828730542675887906815309351994017139223602571716627453741502624516group.public
97105
}" 50u64
98106
```
107+
Output
108+
```bash
109+
• {
110+
owner: aleo1zeklp6dd8e764spe74xez6f8w27dlua3w7hl4z2uln03re52egpsv46ngg.private,
111+
amount: 50u64.private,
112+
_nonce: 832449386206374072274231152033740843999312028336559467119808470542606777523group.public
113+
}
114+
• {
115+
program_id: basic_bank.aleo,
116+
function_name: deposit,
117+
arguments: [
118+
1197470102489602745811042362685620817855019264965533852603090875444599354527field,
119+
50u64
120+
]
121+
}
122+
```
99123

100-
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.
124+
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.
101125

102126
## <a id="wait"></a> Wait
103127

104128
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.
105129

106-
You can run the calculation yourself, it comes out to 266 tokens accrued using those numbers.
130+
You can run the calculation yourself, it comes out to 266 tokens accrued using those numbers.
107131

108132
## <a id="withdraw"></a> Withdraw Tokens
109133

@@ -117,7 +141,22 @@ PRIVATE_KEY=APrivateKey1zkpHtqVWT6fSHgUMNxsuVf7eaR6id2cj7TieKY1Z8CP5rCD
117141

118142
leo run withdraw aleo1zeklp6dd8e764spe74xez6f8w27dlua3w7hl4z2uln03re52egpsv46ngg 50u64 1234u64 15u64
119143
```
120-
144+
Output
145+
```bash
146+
• {
147+
owner: aleo1zeklp6dd8e764spe74xez6f8w27dlua3w7hl4z2uln03re52egpsv46ngg.private,
148+
amount: 266u64.private,
149+
_nonce: 7051804730047578560256662070932795007350207323461845976313826737097831996144group.public
150+
}
151+
• {
152+
program_id: basic_bank.aleo,
153+
function_name: withdraw,
154+
arguments: [
155+
1197470102489602745811042362685620817855019264965533852603090875444599354527field,
156+
50u64
157+
]
158+
}
159+
```
121160
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.
122161

123162
```

0 commit comments

Comments
 (0)