Created
April 13, 2018 14:50
-
-
Save troggy/8287b1c714f951e0da7fd27ebf842e5b to your computer and use it in GitHub Desktop.
Simple CrowdsaleWithPresale contract
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.18; | |
import "zeppelin-solidity/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol"; | |
/** | |
* @title CrowdsaleWithPresale | |
* @dev Extension of IncreasingPriceCrowdsale contract that increases the price of tokens | |
* once the specified period has elapsed (presale time). | |
*/ | |
contract CrowdsaleWithPresale is IncreasingPriceCrowdsale { | |
uint256 public presaleClosingTime; | |
function CrowdsaleWithPresale(uint256 _presaleClosingTime) public { | |
presaleClosingTime = _presaleClosingTime; | |
} | |
/** | |
* @dev Checks whether the period in which the presale is open has already elapsed. | |
* @return Whether presale period has elapsed | |
*/ | |
function presaleClosed() public view returns (bool) { | |
return now > presaleClosingTime; | |
} | |
/** | |
* @dev Returns the rate of tokens per wei at the present time. | |
* Note that, as price _increases_ with time, the rate _decreases_. | |
* @return The number of tokens a buyer gets per wei at a given time | |
*/ | |
function getCurrentRate() public view returns (uint256) { | |
return presaleClosed() ? finalRate : initialRate; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment