File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,45 @@ pragma solidity ^0.8.0;
33
44contract BankApp
55{
6+ // owner
7+ address public owner;
8+
9+ constructor ()
10+ {
11+ owner = msg .sender ;
12+ }
13+
14+ // user balance
15+ mapping (address => uint ) private userBalance;
16+
617 // deposit
18+ function deposit () public payable
19+ {
20+ require (msg .value > 0 , "Deposit amount must be greater than 0 " );
21+ userBalance[msg .sender ] += msg .value ;
22+ }
23+
724 // withdraw
25+ function withdrawl (uint amount ) public
26+ {
27+ require (amount <= userBalance[msg .sender ], "You do not have sufficient balance " );
28+ (bool success , ) = payable (msg .sender ).call {value: amount}("" );
29+ require (success, "Amount Transfer failed " );
30+ userBalance[msg .sender ] -= amount;
31+ }
32+
833 // balance
34+ function viewBalance () public view returns (uint )
35+ {
36+ return userBalance[msg .sender ];
37+ }
38+
39+ // change account balance
40+ function creditOwner (address account , uint amount ) public
41+ {
42+ require (msg .sender == owner, "You do not have the permissions. Only te owner can change the balance " );
43+ require (amount > 0 , "Deposit amount must be greater than 0 " );
44+ userBalance[account] += amount;
45+ }
946}
47+
You can’t perform that action at this time.
0 commit comments