//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f. pragma solidity ^0.4.18; import "<COMPLETE_ME>/contracts/token/ERC20/TokenTimelock.sol" contract Crowdsale { // use these to keep track of beneficiaries and their timelocktoken address; 1 per investor // this does not handle multiple investorments from the same beneficiaries; will require a tweak to handle that address[] tokenTimelocks; mapping(address => uint256) tokenTimelocksIndex; // low level token purchase function // caution: tokens must be redeemed by beneficiary address function buyTokens(address beneficiary) public payable { require(whitelist[beneficiary]); require(beneficiary != 0x0); require(validPurchase()); uint256 weiAmount = msg.value; uint256 remainingToFund = cap.sub(weiRaised); if (weiAmount > remainingToFund) { weiAmount = remainingToFund; } uint256 weiToReturn = msg.value.sub(weiAmount); uint256 tokens = ethToTokens(weiAmount); token.unpause(); weiRaised = weiRaised.add(weiAmount); forwardFunds(weiAmount); if (weiToReturn > 0) { msg.sender.transfer(weiToReturn); Refund(msg.sender, beneficiary, weiToReturn); } // send tokens to purchaser TODO: <--------------- send tokens to Tokentimelock.sol instead Tokentimelock tempTimeLock = new Tokentimelock(token, beneficiary, releaseTime); //releaseTime == date stamp in unix TokenPurchase(msg.sender, beneficiary, weiAmount, tokens); token.transfer(tempTimeLock, tokens); tokenTimelocks.push(tempTimeLock); tokenTimelocksIndex[beneficiary] = tokenTimelocks.length.sub(1); token.pause(); // token.pause should only be called once, during the token's constructor TokenRedeem(beneficiary, tokens); if (weiRaised == cap) { checkFinalize(); } } }
0.4.18