contract ERC20StdToken is Ownable, SafeMath {
  uint256 public totalSupply;
	string  public name;
	uint8   public decimals;
	string  public symbol;
	bool    public isMint;     // 是否可增发
    bool    public isBurn;    // 是否可销毁
    bool    public isFreeze; // 是否可冻结

  mapping (address => uint256) public balanceOf;
  mapping (address => uint256) public freezeOf;
  mapping (address => mapping (address => uint256)) public allowance;

  constructor(
    address _owner,
    string _name,
    string _symbol,
    uint8 _decimals,
    uint256 _initialSupply,
    bool _isMint,
    bool _isBurn,
    bool _isFreeze) public {
    require(_owner != address(0));
    owner             = _owner;
  	decimals          = _decimals;
  	symbol            = _symbol;
  	name              = _name;
  	isMint            = _isMint;
    isBurn            = _isBurn;
    isFreeze          = _isFreeze;
  	totalSupply       = _initialSupply * 10 ** uint256(decimals);
    balanceOf[_owner] = totalSupply;
 }

 // This generates a public event on the blockchain that will notify clients
 event Transfer(address indexed _from, address indexed _to, uint256 _value);
 event Approval(address indexed _owner, address indexed _spender, uint256 _value);

 /* This notifies clients about the amount burnt */
 event Burn(address indexed _from, uint256 value);

  /* This notifies clients about the amount frozen */
 event Freeze(address indexed _from, uint256 value);

  /* This notifies clients about the amount unfrozen */
 event Unfreeze(address indexed _from, uint256 value);

 function approve(address _spender, uint256 _value) public returns (bool success) {
   allowance[msg.sender][_spender] = _value;
   emit Approval(msg.sender, _spender, _value);
   success = true;
 }

 /// @notice send `_value` token to `_to` from `msg.sender`
 /// @param _to The address of the recipient
 /// @param _value The amount of token to be transferred
 /// @return Whether the transfer was successful or not
 function transfer(address _to, uint256 _value) public returns (bool success) {
   require(_to != 0);
   require(balanceOf[msg.sender] >= _value);
   require(balanceOf[_to] + _value >= balanceOf[_to]);
   // balanceOf[msg.sender] -= _value;
   balanceOf[msg.sender] = SafeMath.sub(balanceOf[msg.sender], _value);

   // balanceOf[_to] += _value;
   balanceOf[_to] = SafeMath.add(balanceOf[_to], _value);

   emit Transfer(msg.sender, _to, _value);
   success = true;
 }

 /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
 /// @param _from The address of the sender
 /// @param _to The address of the recipient
 /// @param _value The amount of token to be transferred
 /// @return Whether the transfer was successful or not
 function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
   require(_to != 0);
   require(balanceOf[_from] >= _value);
   require(allowance[_from][msg.sender] >= _value);
   require(balanceOf[_to] + _value >= balanceOf[_to]);
   // balanceOf[_from] -= _value;
   balanceOf[_from] = SafeMath.sub(balanceOf[_from], _value);
   // balanceOf[_to] += _value;
   balanceOf[_to] = SafeMath.add(balanceOf[_to], _value);

   // allowance[_from][msg.sender] -= _value;
   allowance[_from][msg.sender] = SafeMath.sub(allowance[_from][msg.sender], _value);

   emit Transfer(_from, _to, _value);
   success = true;
 }

  function mint(uint256 amount) onlyOwner public {
  	require(isMint);
  	require(amount >= 0);
  	// balanceOf[msg.sender] += amount;
    balanceOf[msg.sender] = SafeMath.add(balanceOf[msg.sender], amount);
  	// totalSupply += amount;
    totalSupply = SafeMath.add(totalSupply, amount);
  }

  function burn(uint256 _value) public returns (bool success) {
    require(balanceOf[msg.sender] >= _value);            // Check if the sender has enough
    require(_value > 0);
    balanceOf[msg.sender] = SafeMath.sub(balanceOf[msg.sender], _value);                      // Subtract from the sender
    totalSupply = SafeMath.sub(totalSupply, _value);                                // Updates totalSupply
    emit Burn(msg.sender, _value);
    success = true;
 }

  function freeze(uint256 _value) public returns (bool success) {
    require(balanceOf[msg.sender] >= _value);            // Check if the sender has enough
    require(_value > 0);
    balanceOf[msg.sender] = SafeMath.sub(balanceOf[msg.sender], _value);                      // Subtract from the sender
    freezeOf[msg.sender] = SafeMath.add(freezeOf[msg.sender], _value);                                // Updates totalSupply
    emit Freeze(msg.sender, _value);
    success = true;
  }

  function unfreeze(uint256 _value) public returns (bool success) {
    require(freezeOf[msg.sender] >= _value);            // Check if the sender has enough
    require(_value > 0);
    freezeOf[msg.sender] = SafeMath.sub(freezeOf[msg.sender], _value);                      // Subtract from the sender
    balanceOf[msg.sender] = SafeMath.add(balanceOf[msg.sender], _value);
    emit Unfreeze(msg.sender, _value);
    success = true;
  }
}
function transfer(address _to, uint256 _value) public returns (bool success) {
  require(_to != 0);
  require(balanceOf[msg.sender] >= _value);
  require(balanceOf[_to] + _value >= balanceOf[_to]);
  // balanceOf[msg.sender] -= _value;
  balanceOf[msg.sender] = SafeMath.sub(balanceOf[msg.sender], _value);

  // balanceOf[_to] += _value;
  balanceOf[_to] = SafeMath.add(balanceOf[_to], _value);

  emit Transfer(msg.sender, _to, _value);
  success = true;
}

/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not