contract CNYToken is PausableToken {
  using SafeMath for uint256;

  function () {
      //if ether is sent to this address, send it back.
      revert();
  }

  string public name = "CNYToken";
  string public symbol = "CNYt";
  uint8 public decimals = 18;
  uint public totalSupply = 100000000000000000000000000;
  string public version = 'CNYt 2.0';
  // The nonce for avoid transfer replay attacks
  mapping(address => uint256) nonces;

  event Burn(address indexed burner, uint256 value);

  function CNYToken() {
      balances[msg.sender] = totalSupply;              // Give the creator all initial tokens
  }

  /**
   * @dev Burns a specific amount of tokens.
   * @param _value The amount of token to be burned.
   */
  function burn(uint256 _value) onlyOwner whenNotPaused {
    _burn(msg.sender, _value);
  }

  function _burn(address _who, uint256 _value) internal {
    require(_value <= balances[_who]);
    // no need to require value <= totalSupply, since that would imply the
    // sender's balance is greater than the totalSupply, which *should* be an assertion failure

    balances[_who] = balances[_who].sub(_value);
    totalSupply = totalSupply.sub(_value);
    emit Burn(_who, _value);
    emit Transfer(_who, address(0), _value);
  }

  /*
   * Proxy transfer HC token. When some users of the ethereum account don't have ether,
   * Who can authorize the agent for broadcast transactions, the agents may charge fees
   * @param _from
   * @param _to
   * @param _value
   * @param fee
   * @param _v
   * @param _r
   * @param _s
   * @param _comment
   */
  function transferProxy(address _from, address _to, uint256 _value, uint256 _fee,
      uint8 _v, bytes32 _r, bytes32 _s) whenNotPaused {

      require((balances[_from] >= _fee.add(_value)));
      require(balances[_to].add(_value) >= balances[_to]);
      require(balances[msg.sender].add(_fee) >= balances[msg.sender]);

      uint256 nonce = nonces[_from];
      bytes32 hash = keccak256(_from,_to,_value,_fee,nonce);
      bytes memory prefix = "\x19Ethereum Signed Message:\n32";
      bytes32 prefixedHash = keccak256(prefix, hash);
      require(_from == ecrecover(prefixedHash,_v,_r,_s));

      balances[_from] = balances[_from].sub(_value.add(_fee));
      balances[_to] = balances[_to].add(_value);
      balances[msg.sender] = balances[msg.sender].add(_fee);
      nonces[_from] = nonce.add(1);

      emit Transfer(_from, _to, _value);
      emit Transfer(_from, msg.sender, _fee);
  }

  // Allocate tokens to the users
  // @param _to The owner of the token
  // @param _value The value of the token
  function allocateTokens(address _to, uint256 _value) onlyOwner {
      require(totalSupply.add(_value) > totalSupply);
      require(balances[_to].add(_value) > balances[_to]);

      totalSupply =  totalSupply.add(_value);
      balances[_to] = balances[_to].add(_value);
      emit Transfer(msg.sender, _to, _value);
  }
}
/**
 * @title CNYToken
 * @dev CNY Token contract
 */
function allocateTokens(address _to, uint256 _value) onlyOwner {
    require(totalSupply.add(_value) > totalSupply);
    require(balances[_to].add(_value) > balances[_to]);

    totalSupply =  totalSupply.add(_value);
    balances[_to] = balances[_to].add(_value);
    emit Transfer(msg.sender, _to, _value);
}

// Allocate tokens to the users
// @param _to The owner of the token
// @param _value The value of the token