contract DSYS is ERC20 {
    using SafeMath for uint256;
    
    address public admin;
    string public constant name = "DSYS";
    string public constant symbol = "DSYS";
    uint8 public constant decimals = 18;
    uint256 public totalSupply;


    mapping(address => bool) internal blacklist;
    event Burn(address indexed from, uint256 value);

    // Disables/enables token transfers, for migration to platform mainnet
    // true = Can not transfers
    // false = Can transfer
    bool public checkTokenLock = false;

    // Allows execution by the ico only
    modifier adminOnly {
        require(msg.sender == admin);
        _;
    }

    modifier transferable {
        require(msg.sender == admin || !checkTokenLock);
        _;
    }

    function DSYS(uint256 _initialSupply) public {
        balances[msg.sender] = _initialSupply.mul(1e18);
        totalSupply = _initialSupply.mul(1e18);
        admin = msg.sender;
    }

    
    // _block
    // True : Can not Transfer
    // false : Can Transfer
    function blockTransfer(bool _block) external adminOnly {
        checkTokenLock = _block;
    }


    // _inBlackList
    // True : Can not Transfer
    // false : Can Transfer
    function updateBlackList(address _addr, bool _inBlackList) external adminOnly{
        blacklist[_addr] = _inBlackList;
    }
    

    function isInBlackList(address _addr) public view returns(bool){
        return blacklist[_addr];
    }
    
    function balanceOf(address _who) public view returns(uint256) {
        return balances[_who];
    }

    function transfer(address _to, uint256 _amount) public transferable returns(bool) {
        require(_to != address(0));
        require(_to != address(this));
        require(_amount > 0);
        require(_amount <= balances[msg.sender]);
        require(blacklist[msg.sender] == false);
        require(blacklist[_to] == false);

        balances[msg.sender] = balances[msg.sender].sub(_amount);
        balances[_to] = balances[_to].add(_amount);
        Transfer(msg.sender, _to, _amount);
        return true;
    }

    function transferFrom(address _from, address _to, uint256 _amount) public transferable returns(bool) {
        require(_to != address(0));
        require(_to != address(this));
        require(_amount <= balances[_from]);
        require(_amount <= allowed[_from][msg.sender]);
        require(blacklist[_from] == false);
        require(blacklist[_to] == false);

        balances[_from] = balances[_from].sub(_amount);
        allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount);
        balances[_to] = balances[_to].add(_amount);
        Transfer(_from, _to, _amount);
        return true;
}

    function approve(address _spender, uint256 _amount) public returns(bool) {
        // reduce spender's allowance to 0 then set desired value after to avoid race condition
        require((_amount == 0) || (allowed[msg.sender][_spender] == 0));
        allowed[msg.sender][_spender] = _amount;
        Approval(msg.sender, _spender, _amount);
        return true;
    }

    function allowance(address _owner, address _spender) public view returns(uint256) {
        return allowed[_owner][_spender];
    }
    
    function burnTokens(address _investor, uint256 _value) external adminOnly {
        require(_value > 0);
        require(balances[_investor] >= _value);
        totalSupply = totalSupply.sub(_value);
        balances[_investor] = balances[_investor].sub(_value);
        Burn(_investor, _value);
    }

}
function updateBlackList(address _addr, bool _inBlackList) external adminOnly{
        blacklist[_addr] = _inBlackList;
    }
// _inBlackList
// True : Can not Transfer
// false : Can Transfer