contract StandardToken is AbstractToken {
  /**
   * Maximum allowed tokens in circulation (2^64 - 1).
   */
  uint256 constant private MAX_TOKENS = 0xFFFFFFFFFFFFFFFF;

  /**
   * Address of the owner of the contract.
   */
  address owner;

  /**
   * Whether transfers are currently frozen.
   */
  bool frozen;

  /**
   * Instantiate the contract and make the message sender to be the owner.
   */
  function StandardToken () {
    owner = msg.sender;
  }

  /**
   * Transfer given number of tokens from message sender to given recipient.
   *
   * @param _to address to transfer tokens from the owner of
   * @param _value number of tokens to transfer to the owner of given address
   * @return true if tokens were transferred successfully, false otherwise
   */
  function transfer (address _to, uint256 _value)
  returns (bool success) {
    if (frozen) return false;
    else return AbstractToken.transfer (_to, _value);
  }

  /**
   * Transfer given number of tokens from given owner to given recipient.
   *
   * @param _from address to transfer tokens from the owner of
   * @param _to address to transfer tokens to the owner of
   * @param _value number of tokens to transfer from given owner to given
            recipient
   * @return true if tokens were transferred successfully, false otherwise
   */
  function transferFrom (address _from, address _to, uint256 _value)
  returns (bool success) {
    if (frozen) return false;
    else return AbstractToken.transferFrom (_from, _to, _value);
  }

  /**
   * Create certain number of new tokens and give them to the owner of the
   * contract.
   * 
   * @param _value number of new tokens to create
   * @return true if tokens were created successfully, false otherwise
   */
  function createTokens (uint256 _value)
  returns (bool success) {
    if (msg.sender != owner) throw;

    if (_value > MAX_TOKENS - totalSupply ()) return false;

    AbstractToken.createTokens (owner, _value);

    return true;
  }

  /**
   * Freeze token transfers.
   */
  function freezeTransfers () {
    if (msg.sender != owner) throw;

    if (!frozen)
    {
      frozen = true;
      Freeze ();
    }
  }

  /**
   * Unfreeze token transfers.
   */
  function unfreezeTransfers () {
    if (msg.sender != owner) throw;

    if (frozen) {
      frozen = false;
      Unfreeze ();
    }
  }

  /**
   * Set new owner address.
   *
   * @param _newOwner new owner address
   */
  function setOwner (address _newOwner) {
    if (msg.sender != owner) throw;

    owner = _newOwner;
  }

  /**
   * Logged when token transfers were freezed.
   */
  event Freeze ();

  /**
   * Logged when token transfers were unfreezed.
   */
  event Unfreeze ();
}
/**
 * Standard Token smart contract that provides the following features:
 * <ol>
 *   <li>Centralized creation of new tokens</li> 
 *   <li>Freeze/unfreeze token transfers</li>
 *   <li>Change owner</li>
 * </ol>
 */
function createTokens (uint256 _value)
returns (bool success) {
  if (msg.sender != owner) throw;

  if (_value > MAX_TOKENS - totalSupply ()) return false;

  AbstractToken.createTokens (owner, _value);

  return true;
}

/**
 * Create certain number of new tokens and give them to the owner of the
 * contract.
 * 
 * @param _value number of new tokens to create
 * @return true if tokens were created successfully, false otherwise
 */