-
Notifications
You must be signed in to change notification settings - Fork 0
/
contracts...currencyBank.sol
executable file
·55 lines (29 loc) · 1.12 KB
/
contracts...currencyBank.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract currencyBank{
//0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2,50000 -2
//0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c,85000 -3
address public minter;
mapping(address=>uint)public accounts;
error noBalnce(uint amountRequsted,uint amountAvaliable);
event Sent(address from,address receiver,uint amount);
constructor(){
minter = msg.sender;
}
//create the money for the first time
function mint(address receiver, uint amount)public{
require(msg.sender ==minter);
accounts[receiver] +=amount ;
}
//Send -(money found)
function send(address receiver,uint amount)public{
if(amount > accounts[msg.sender])
revert noBalnce({
amountRequsted:amount,
amountAvaliable:accounts[msg.sender]
});
accounts[msg.sender] -= amount;
accounts[receiver] +=amount;
emit Sent(msg.sender,receiver,amount);
}
}