2016-08-19 14:51:40 +00:00
|
|
|
import "./Token.sol";
|
2016-08-17 14:53:21 +00:00
|
|
|
|
2016-08-19 14:49:50 +00:00
|
|
|
contract StandardToken is Token {
|
2016-08-17 14:53:21 +00:00
|
|
|
uint256 tokenSupply;
|
|
|
|
mapping (address => uint256) balances;
|
|
|
|
mapping (address =>
|
|
|
|
mapping (address => uint256)) approvedTransfers;
|
|
|
|
|
2016-08-19 14:49:50 +00:00
|
|
|
function StandardToken(address _initialOwner, uint256 _supply) {
|
2016-08-17 14:53:21 +00:00
|
|
|
tokenSupply = _supply;
|
|
|
|
balances[_initialOwner] = _supply;
|
|
|
|
}
|
|
|
|
|
|
|
|
function totalSupply() constant returns (uint256 supply) {
|
|
|
|
return tokenSupply;
|
|
|
|
}
|
|
|
|
|
|
|
|
function balanceOf(address _owner) constant returns (uint256 balance) {
|
|
|
|
return balances[_owner];
|
|
|
|
}
|
|
|
|
|
|
|
|
function transfer(address _to, uint256 _value) returns (bool success) {
|
|
|
|
if (balances[msg.sender] >= _value) {
|
|
|
|
balances[msg.sender] -= _value;
|
|
|
|
balances[_to] += _value;
|
|
|
|
Transfer(msg.sender, _to, _value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
|
|
|
|
if (approvedTransfers[_from][msg.sender] >= _value) {
|
|
|
|
approvedTransfers[_from][msg.sender] -= _value;
|
|
|
|
balances[_to] += _value;
|
|
|
|
Transfer(_from, _to, _value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function approve(address _spender, uint256 _value) returns (bool success) {
|
|
|
|
approvedTransfers[msg.sender][_spender] = _value;
|
|
|
|
Approval(msg.sender, _spender, _value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
|
|
|
|
return approvedTransfers[_owner][_spender];
|
|
|
|
}
|
|
|
|
}
|