contract SwissCryptoExchangeToken is ERC20Basic, Versionable {
  event Mint(address indexed to, uint256 amount);

  using SafeMath for uint256;

  mapping(address => uint256) balances;

  string public constant symbol = "SCX";
  uint8 public constant decimals = 0;

  uint256 internal constant COMPANY_CONTRACT_ID = 101;

  /**
   * Create a new instance of the SwissCryptoExchangeToken contract.
   * @param initialShareholderAddress address 
   * @param initialAmount             uint256 
   */
  function SwissCryptoExchangeToken (address initialShareholderAddress, uint256 initialAmount, address _manager)
    public
    Manageable (_manager)
    Versionable ("SwissCryptoExchangeToken", "1.0.0", 1)
  {
    require(initialAmount > 0);
    require(initialShareholderAddress != 0x0);

    balances[initialShareholderAddress] = initialAmount;
    totalSupply = initialAmount;
  }

  /**
   * @dev Esnure the msg.sender is the company contract.
   */
  modifier onlyCompany() {
    require (msg.sender == ContractManagementSystem(manager).getActiveContractAddress(COMPANY_CONTRACT_ID));
    _;
  }

  /**
  * @dev Gets the balance of the specified address.
  * @param _owner The address to query the the balance of.
  * @return An uint256 representing the amount owned by the passed address.
  */
  function balanceOf(address _owner) public view returns (uint256 balance) {
    return balances[_owner];
  }

  /**
  * @dev Transfer token for a specified address
  * @param _to The address to transfer to.
  * @param _value The amount to be transferred.
  */
  function transfer(address _to, uint256 _value) public isActive onlyCompany returns (bool) {
    require(_to != 0x0);
    require(_value <= balances[msg.sender]);

    // SafeMath.sub will throw if there is not enough balance.
    balances[msg.sender] = balances[msg.sender].sub(_value);
    balances[_to] = balances[_to].add(_value);
    Transfer(msg.sender, _to, _value);
    return true;
  }

  /**
   * @dev Transfer tokens from one address to another.
   * @param _from address The address which you want to send tokens from
   * @param _to address The address which you want to transfer to
   * @param _value uint256 the amount of tokens to be transferred
   */
  function transferFrom(address _from, address _to, uint256 _value) public isActive onlyCompany returns (bool) {
    require(_to != 0x0);
    require(_value <= balances[_from]);

    balances[_from] = balances[_from].sub(_value);
    balances[_to] = balances[_to].add(_value);
    Transfer(_from, _to, _value);
    return true;
  }

  /**
   * @dev Function to mint tokens.
   * @param _amount The amount of tokens to mint.
   * @return A boolean that indicates if the operation was successful.
   */
  function mint(uint256 _amount) isActive onlyCompany public returns (bool) {
    // The receiver of the minted tokens will be the company contract.
    address _companyAddress = ContractManagementSystem(manager).getActiveContractAddress(COMPANY_CONTRACT_ID);
    totalSupply = totalSupply.add(_amount);
    balances[_companyAddress] = balances[_companyAddress].add(_amount);
    Mint(_companyAddress, _amount);
    Transfer(0x0, _companyAddress, _amount);
    return true;
  }
}
/**
 * @title SwissCryptoExchange Standard ERC20 compatible token
 *
 * @dev Implementation of the SwissCryptoExchange company shares.
 * @dev Based on code by OpenZeppelin: https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/token/StandardToken.sol
 */
function balanceOf(address _owner) public view returns (uint256 balance) {
  return balances[_owner];
}

/**
 * @dev Gets the balance of the specified address.
 * @param _owner The address to query the the balance of.
 * @return An uint256 representing the amount owned by the passed address.
 */