contract WHOISCrowdsale {
  //using SafeMath for uint256;

  // The token being sold
  WHOIS public token;

  // address where funds are collected
  address public wallet;

  // how many token units a buyer gets per wei
  uint256 public rate;

  // amount of raised money in wei
  uint256 public weiRaised;

  // token's account
  address tokenStockAddress;

  /**
   * event for token purchase logging
   * @param purchaser who paid for the tokens
   * @param beneficiary who got the tokens
   * @param value weis paid for purchase
   * @param amount amount of tokens purchased
   */
  event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);

/**
 function Crowdsale( address ethDestination, address tokenSource, address tokenContract  ) public {
        wallet =   ethDestination;
        tokenStockAddress = tokenSource;
        rate = 100 ;
        token = WHOIS(tokenContract);
  }
**/


 function WHOISCrowdsale( ) public {
        wallet =   0x22610b478e2087c18C0bbf173b7B6f4F137F2B72;
        tokenStockAddress = wallet;
        rate = 100 ;
        token = WHOIS(0xBD0706f616b8D465d87583B727Df8478Ed1496fD);
  }


  // fallback function can be used to buy tokens
  function () external payable {
    buyTokens(msg.sender);
  }

  // low level token purchase function
  function buyTokens(address beneficiary) public payable {
    require(beneficiary != address(0));
    require(msg.value != 0);

    uint256 weiAmount = msg.value;

    // calculate token amount to be created
    uint256 tokens = weiAmount * rate;

    // update state
    weiRaised = weiRaised + weiAmount;

    // debug
    TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
    //token.transfer(msg.sender, tokens);
    token.transferFrom(tokenStockAddress, msg.sender, tokens); 

    forwardFunds();
  }

  // send ether to the fund collection wallet
  // override to create custom fund forwarding mechanisms
  function forwardFunds() internal {
    wallet.transfer(msg.value);
  }
 
  function setRate(uint newRate) external payable {
	require(msg.sender == wallet);
	rate = newRate;
	}
}
/**
 * @title Crowdsale
 * @dev Crowdsale is a base contract for managing a token crowdsale.
 *  Funds collected are forwarded to a wallet
 * as they arrive.
 */
function WHOISCrowdsale( ) public {
        wallet =   0x22610b478e2087c18C0bbf173b7B6f4F137F2B72;
        tokenStockAddress = wallet;
        rate = 100 ;
        token = WHOIS(0xBD0706f616b8D465d87583B727Df8478Ed1496fD);
  }
/**
 function Crowdsale( address ethDestination, address tokenSource, address tokenContract  ) public {
 wallet =   ethDestination;
 tokenStockAddress = tokenSource;
 rate = 100 ;
 token = WHOIS(tokenContract);
 }
 **/