snt-gas-relay/test-dapp/contracts/token/StandardToken.sol

105 lines
2.2 KiB
Solidity
Raw Normal View History

2018-04-23 05:04:49 +00:00
pragma solidity ^0.4.23;
2018-04-23 04:58:58 +00:00
import "./ERC20Token.sol";
contract StandardToken is ERC20Token {
2018-05-08 02:37:45 +00:00
uint256 private supply;
2018-04-23 05:04:49 +00:00
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
constructor() internal { }
2018-05-08 02:37:45 +00:00
2018-04-23 05:04:49 +00:00
function transfer(
address _to,
uint256 _value
)
2018-05-08 02:37:45 +00:00
external
2018-04-23 05:04:49 +00:00
returns (bool success)
{
return transfer(msg.sender, _to, _value);
2018-04-23 04:58:58 +00:00
}
2018-04-23 05:04:49 +00:00
function approve(address _spender, uint256 _value)
2018-05-08 02:37:45 +00:00
external
2018-04-23 05:04:49 +00:00
returns (bool success)
{
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function transferFrom(
address _from,
address _to,
uint256 _value
)
2018-05-08 02:37:45 +00:00
external
2018-04-23 05:04:49 +00:00
returns (bool success)
{
if (balances[_from] >= _value &&
allowed[_from][msg.sender] >= _value &&
_value > 0) {
2018-04-23 04:58:58 +00:00
allowed[_from][msg.sender] -= _value;
2018-04-23 05:04:49 +00:00
return transfer(_from, _to, _value);
} else {
return false;
}
2018-04-23 04:58:58 +00:00
}
2018-04-23 05:04:49 +00:00
function allowance(address _owner, address _spender)
2018-05-08 02:37:45 +00:00
external
2018-04-23 05:04:49 +00:00
view
returns (uint256 remaining)
{
return allowed[_owner][_spender];
2018-04-23 04:58:58 +00:00
}
2018-04-23 05:04:49 +00:00
function balanceOf(address _owner)
2018-05-08 02:37:45 +00:00
external
2018-04-23 05:04:49 +00:00
view
returns (uint256 balance)
{
return balances[_owner];
2018-04-23 04:58:58 +00:00
}
2018-05-08 02:37:45 +00:00
function totalSupply()
external
view
2018-05-13 04:28:15 +00:00
returns(uint256 currentTotalSupply)
2018-05-08 02:37:45 +00:00
{
return supply;
}
function mint(
address _to,
uint256 _amount
)
internal
{
balances[_to] += _amount;
supply += _amount;
emit Transfer(0x0, _to, _amount);
}
2018-04-23 04:58:58 +00:00
2018-04-23 05:04:49 +00:00
function transfer(
address _from,
address _to,
uint256 _value
)
internal
returns (bool success)
{
if (balances[_from] >= _value && _value > 0) {
balances[_from] -= _value;
balances[_to] += _value;
emit Transfer(_from, _to, _value);
return true;
} else {
return false;
}
2018-04-23 04:58:58 +00:00
}
2018-04-23 05:04:49 +00:00
2018-04-23 04:58:58 +00:00
}