-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimpleBank.sol
23 lines (19 loc) · 888 Bytes
/
SimpleBank.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// A simple bank smart contract where the user can deposit and query funds.
pragma solidity >=0.4.22 <0.6.0;
contract SimpleBank {
// this declares a key/value array called balanceAccount.
// the key is address and the value is an unsigned integer
mapping (address => uint) balanceAccount;
address public banker = msg.sender;
// Declare a deposit function that takes an input called amount
function deposit(uint amount) public {
require (msg.sender == banker, "Only banker can make a deposit");
// add amount to the balance of the sender
balanceAccount[msg.sender] += amount;
}
// a getBalance function that accepts no inputs but returns
// the amount in the balanceAccount array
function getBalance() public view returns (uint balance){
return balanceAccount[msg.sender];
}
}