-
Notifications
You must be signed in to change notification settings - Fork 0
/
Blockmason.Coins.sol
47 lines (36 loc) · 1.2 KB
/
Blockmason.Coins.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
pragma solidity ^0.5.8;
contract Coins {
mapping (uint256 => uint256) private balances;
uint256 private supplyAmount;
address private authority;
constructor() public {
authority = msg.sender;
}
function supply() public view returns (uint256 amount) {
return supplyAmount;
}
function balance(uint256 holder) public view returns (uint256 amount) {
return balances[holder];
}
function mint(uint256 holder, uint256 amount) public {
require(msg.sender == authority);
require(balances[holder] < balances[holder] + amount);
require(supplyAmount < supplyAmount + amount);
supplyAmount += amount;
balances[holder] += amount;
}
function burn(uint256 holder, uint256 amount) public {
require(msg.sender == authority);
require(balances[holder] - amount < balances[holder]);
require(supplyAmount - amount < supplyAmount);
balances[holder] -= amount;
supplyAmount -= amount;
}
function transfer(uint256 from, uint256 to, uint256 amount) public {
require(msg.sender == authority);
require(balances[from] - amount < balances[from]);
require(balances[to] < balances[to] + amount);
balances[from] -= amount;
balances[to] += amount;
}
}