-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRBAC-2b.sol
67 lines (51 loc) · 1.8 KB
/
RBAC-2b.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
56
57
58
59
60
61
62
63
64
65
66
67
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.10;
library SafeMath {
function add(uint256 x, uint256 y) internal pure returns (uint256) {
uint256 z = x + y;
require(z >= x, "uint overflow");
return z;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
uint256 c = a - b;
return c;
}
}
interface IToken{
function transfer(address _receipient, uint256 _amount) external returns(bool);
function totalSupply() external returns(uint256);
function balanceOf(address owner) external returns(uint256);
}
contract StandardToken is IToken {
using SafeMath for uint256;
// state variables
address public _owner;
mapping (address => uint256) public _balances;
uint256 _totalSupply;
string _name;
string _symbol;
constructor () public {
_owner = msg.sender;
_name = "yorkcoin";
_symbol = "yc";
_totalSupply = 1000;
}
function mint(address owner, uint256 amount) public {
require(msg.sender == _owner, "Unauthorized");
_totalSupply = _totalSupply.add(amount);
_balances[owner] = _balances[owner].add(amount);
}
function transfer(address _receipient, uint256 _amount) public override returns (bool) {
require(msg.sender == _owner, "Unauthorized");
_balances[_owner] = _balances[_owner].sub(_amount);
_balances[_receipient] = _balances[_receipient].add(_amount);
return true;
}
function balanceOf(address owner) public override returns (uint256) {
return _balances[owner];
}
function totalSupply() public override returns (uint256) {
return _totalSupply;
}
}