You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.5 KiB
55 lines
1.5 KiB
pragma solidity ^0.4.21;
|
|
|
|
import "../../math/SafeMath.sol";
|
|
import "../Crowdsale.sol";
|
|
|
|
|
|
/**
|
|
* @title TimedCrowdsale
|
|
* @dev Crowdsale accepting contributions only within a time frame.
|
|
*/
|
|
contract TimedCrowdsale is Crowdsale {
|
|
using SafeMath for uint256;
|
|
|
|
uint256 public openingTime;
|
|
uint256 public closingTime;
|
|
|
|
/**
|
|
* @dev Reverts if not in crowdsale time range.
|
|
*/
|
|
modifier onlyWhileOpen {
|
|
require(block.timestamp >= openingTime && block.timestamp <= closingTime);
|
|
_;
|
|
}
|
|
|
|
/**
|
|
* @dev Constructor, takes crowdsale opening and closing times.
|
|
* @param _openingTime Crowdsale opening time
|
|
* @param _closingTime Crowdsale closing time
|
|
*/
|
|
function TimedCrowdsale(uint256 _openingTime, uint256 _closingTime) public {
|
|
require(_openingTime >= block.timestamp);
|
|
require(_closingTime >= _openingTime);
|
|
|
|
openingTime = _openingTime;
|
|
closingTime = _closingTime;
|
|
}
|
|
|
|
/**
|
|
* @dev Checks whether the period in which the crowdsale is open has already elapsed.
|
|
* @return Whether crowdsale period has elapsed
|
|
*/
|
|
function hasClosed() public view returns (bool) {
|
|
return block.timestamp > closingTime;
|
|
}
|
|
|
|
/**
|
|
* @dev Extend parent behavior requiring to be within contributing period
|
|
* @param _beneficiary Token purchaser
|
|
* @param _weiAmount Amount of wei contributed
|
|
*/
|
|
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal onlyWhileOpen {
|
|
super._preValidatePurchase(_beneficiary, _weiAmount);
|
|
}
|
|
|
|
}
|
|
|