Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pragma solidity ^0.4.18;
- /**
- * @title Ownable
- * @dev The Ownable contract has an owner address, and provides basic authorization control
- * functions, this simplifies the implementation of "user permissions".
- */
- contract Ownable {
- address public owner;
- event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
- /**
- * @dev The Ownable constructor sets the original `owner` of the contract to the sender
- * account.
- */
- function Ownable() public {
- owner = msg.sender;
- }
- /**
- * @dev Throws if called by any account other than the owner.
- */
- modifier onlyOwner() {
- require(msg.sender == owner);
- _;
- }
- /**
- * @dev Allows the current owner to transfer control of the contract to a newOwner.
- * @param newOwner The address to transfer ownership to.
- */
- function transferOwnership(address newOwner) onlyOwner public {
- require(newOwner != address(0));
- OwnershipTransferred(owner, newOwner);
- owner = newOwner;
- }
- }
- contract LamdenTau is Ownable, MintableToken {
- string public constant name = "Lamden Tau";
- string public constant symbol = "TAU";
- uint8 public constant decimals = 18;
- // how many ethers have been raised, as contract will not hold any ether
- uint256 public currentRaise = 0;
- // addresses for fund management and permissioning
- address public wallet;
- uint256 public launchTime = 0; // used to determine ico spending cap
- uint256 public constant UNIX_DAY = 86400; // how many seconds in a day. calculates the days from launch time
- // whitelists
- mapping (address => bool) public presaleWhitelist;
- mapping (address => bool) public icoWhitelist;
- // ico cap variables
- mapping (address => uint256) amountContributedBy;
- uint256 amountPerDay = 30 * (10 ** 18); // 30 eth
- modifier onlyPresaleWhitelist()
- {
- require(presaleWhitelist[msg.sender]);
- _;
- }
- modifier onlyicoWhitelist()
- {
- require(icoWhitelist[msg.sender]);
- _;
- }
- // a simple struct to hold information about a sale
- struct Sale {
- uint256 start;
- uint256 stop;
- uint256 cap;
- uint256 price;
- uint256 sold;
- }
- // the two sales
- Sale public presale;
- Sale public ico;
- function LamdenTau(
- uint256 _pstart,
- uint256 _pstop,
- uint256 _pcap,
- uint256 _pprice,
- uint256 _istart,
- uint256 _istop,
- uint256 _icap,
- uint256 _iprice,
- address _wallet) public
- {
- // sanity checks
- require (_pstart < _pstop && _pstop < _istart && _istart < _istop); // presale can't start and stop before the ico
- require (_pcap < _icap); // presale cap must be less than ico cap
- require (_pprice < _iprice); // presale price must be less than ico price
- // set the sale structs for reference at purchase time
- presale = Sale(_pstart, _pstop, _pcap, _pprice, 0);
- ico = Sale(_istart, _istop, _icap, _iprice, 0);
- // set where the ethers are stored
- wallet = _wallet;
- // allocations go here
- // set launch time to now
- launchTime = now;
- }
- function() payable public {
- if (now > presale.start && now < presale.stop) presalePurchase();
- else if (now > ico.start && now < ico.stop) icoPurchase();
- else revert();
- }
- function presalePurchase() internal onlyPresaleWhitelist returns(bool) {
- uint256 tokenAmount = msg.value.div(presale.price);
- uint256 tokensLeft = presale.cap.sub(presale.sold.add(tokenAmount));
- if (tokensLeft > 0) {
- wallet.send(this.value);
- presale.sold = presale.sold.add(tokenAmount);
- mint(tokenAmount, msg.sender);
- return true;
- }
- else revert();
- }
- function icoPurchase() internal onlyicoWhitelist returns(bool) {
- uint256 tokenAmount = msg.value.div(ico.price);
- uint256 tokensLeft = ico.cap.sub(ico.sold.add(tokenAmount));
- uint256 contributionCeiling = amountPerDay.mul((2 ** daysSinceLaunch));
- uint256 personalCeiling = contributionCeiling.sub(amountContributedBy[msg.sender]);
- if (tokensLeft > 0 && personalCeiling > 0) {
- wallet.send(this.value);
- ico.sold = ico.sold.add(tokenAmount);
- mint(tokenAmount, msg.sender);
- uint256 tokenLeftUntilClose = ico.cap.sub(ico.sold);
- if (tokenLeftUntilClose <= 0) finishMinting();
- return true;
- }
- else revert();
- }
- function addToPresaleWhitelist(address _a) internal onlyOwner returns(bool) {
- presaleWhitelist[_a] = true;
- return presaleWhitelist[_a];
- }
- function addtoICOWhitelist(address _a) internal onlyOwner returns(bool) {
- icoWhitelist[_a] = true;
- return icoWhitelist[_a];
- }
- function daysSinceLaunch() public view returns(uint256) {
- return (now.sub(launchTime)) % UNIX_DAY;
- }
- }
Add Comment
Please, Sign In to add comment