-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAssetToken.sol
88 lines (64 loc) · 1.92 KB
/
AssetToken.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
pragma solidity 0.4.8;
contract admined {
address public admin;
function admined(){
admin = msg.sender;
}
modifier onlyAdmin(){
if(msg.sender != admin) throw;
_;
}
function transferAdminship(address newAdmin) onlyAdmin {
admin = newAdmin;
}
}
contract Token {
mapping (address => uint256) public balanceOf;
// balanceOf[address] = 5;
string public name;
string public symbol;
uint8 public decimal;
uint256 public totalSupply;
event Transfer(address indexed from, address indexed to, uint256 value);
function Token(uint256 initialSupply, string tokenName, string tokenSymbol, uint8 decimalUnits){
balanceOf[msg.sender] = initialSupply;
totalSupply = initialSupply;
decimal = decimalUnits;
symbol = tokenSymbol;
name = tokenName;
}
function transfer(address _to, uint256 _value){
if(balanceOf[msg.sender] < _value) throw;
if(balanceOf[_to] + _value < balanceOf[_to]) throw;
//if(admin)
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
Transfer(msg.sender, _to, _value);
}
}
contract AssetToken is admined, Token{
function AssetToken(uint256 initialSupply, string tokenName, string tokenSymbol, uint8 decimalUnits, address centralAdmin) Token (0, tokenName, tokenSymbol, decimalUnits ){
totalSupply = initialSupply;
if(centralAdmin != 0)
admin = centralAdmin;
else
admin = msg.sender;
balanceOf[admin] = initialSupply;
totalSupply = initialSupply;
}
function mintToken(address target, uint256 mintedAmount) onlyAdmin{
balanceOf[target] += mintedAmount;
totalSupply += mintedAmount;
Transfer(0, this, mintedAmount);
Transfer(this, target, mintedAmount);
}
function transfer(address _to, uint256 _value){
if(balanceOf[msg.sender] <= 0) throw;
if(balanceOf[msg.sender] < _value) throw;
if(balanceOf[_to] + _value < balanceOf[_to]) throw;
//if(admin)
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
Transfer(msg.sender, _to, _value);
}
}