SHARE
TWEET

Untitled

a guest Oct 24th, 2017 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. pragma solidity ^0.4.18;
  2.  
  3. /**
  4.  * @title Ownable
  5.  * @dev The Ownable contract has an owner address, and provides basic authorization control
  6.  * functions, this simplifies the implementation of "user permissions".
  7.  */
  8. contract Ownable {
  9.   address public owner;
  10.  
  11.   event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
  12.  
  13.  
  14.   /**
  15.    * @dev The Ownable constructor sets the original `owner` of the contract to the sender
  16.    * account.
  17.    */
  18.    
  19.   function Ownable() public {
  20.     owner = msg.sender;
  21.   }
  22.  
  23.   /**
  24.    * @dev Throws if called by any account other than the owner.
  25.    */
  26.   modifier onlyOwner() {
  27.     require(msg.sender == owner);
  28.     _;
  29.   }
  30.  
  31.  
  32.   /**
  33.    * @dev Allows the current owner to transfer control of the contract to a newOwner.
  34.    * @param newOwner The address to transfer ownership to.
  35.    */
  36.   function transferOwnership(address newOwner) onlyOwner public {
  37.     require(newOwner != address(0));
  38.     OwnershipTransferred(owner, newOwner);
  39.     owner = newOwner;
  40.   }
  41.  
  42. }
  43.  
  44. contract LamdenTau is Ownable, MintableToken {
  45.  
  46.     string public constant name = "Lamden Tau";
  47.     string public constant symbol = "TAU";
  48.     uint8 public constant decimals = 18;
  49.    
  50.     // how many ethers have been raised, as contract will not hold any ether
  51.     uint256 public currentRaise = 0;
  52.    
  53.     // addresses for fund management and permissioning
  54.     address public wallet;
  55.    
  56.     uint256 public launchTime = 0; // used to determine ico spending cap
  57.     uint256 public constant UNIX_DAY = 86400; // how many seconds in a day. calculates the days from launch time
  58.    
  59.     // whitelists
  60.     mapping (address => bool) public presaleWhitelist;
  61.     mapping (address => bool) public icoWhitelist;
  62.    
  63.     // ico cap variables
  64.     mapping (address => uint256) amountContributedBy;
  65.     uint256 amountPerDay = 30 * (10 ** 18); // 30 eth
  66.    
  67.     modifier onlyPresaleWhitelist()
  68.     {
  69.         require(presaleWhitelist[msg.sender]);
  70.         _;
  71.     }
  72.    
  73.     modifier onlyicoWhitelist()
  74.     {
  75.         require(icoWhitelist[msg.sender]);
  76.         _;
  77.     }
  78.    
  79.     // a simple struct to hold information about a sale
  80.     struct Sale {
  81.         uint256 start;
  82.         uint256 stop;
  83.         uint256 cap;
  84.         uint256 price;
  85.         uint256 sold;
  86.     }
  87.    
  88.     // the two sales
  89.     Sale public presale;
  90.     Sale public ico;
  91.    
  92.     function LamdenTau(
  93.         uint256 _pstart,
  94.         uint256 _pstop,
  95.         uint256 _pcap,
  96.         uint256 _pprice,
  97.         uint256 _istart,
  98.         uint256 _istop,
  99.         uint256 _icap,
  100.         uint256 _iprice,
  101.         address _wallet) public
  102.     {
  103.         // sanity checks
  104.         require (_pstart < _pstop && _pstop < _istart && _istart < _istop); // presale can't start and stop before the ico
  105.         require (_pcap < _icap); // presale cap must be less than ico cap
  106.         require (_pprice < _iprice); // presale price must be less than ico price
  107.        
  108.         // set the sale structs for reference at purchase time
  109.         presale = Sale(_pstart, _pstop, _pcap, _pprice, 0);
  110.         ico = Sale(_istart, _istop, _icap, _iprice, 0);
  111.        
  112.         // set where the ethers are stored
  113.         wallet = _wallet;
  114.         // allocations go here
  115.        
  116.         // set launch time to now
  117.         launchTime = now;
  118.     }
  119.    
  120.     function() payable public {
  121.         if (now > presale.start && now < presale.stop) presalePurchase();
  122.         else if (now > ico.start && now < ico.stop) icoPurchase();
  123.         else revert();
  124.     }
  125.    
  126.     function presalePurchase() internal onlyPresaleWhitelist returns(bool) {
  127.         uint256 tokenAmount = msg.value.div(presale.price);
  128.         uint256 tokensLeft = presale.cap.sub(presale.sold.add(tokenAmount));
  129.        
  130.         if (tokensLeft > 0) {
  131.             wallet.send(this.value);
  132.            
  133.             presale.sold = presale.sold.add(tokenAmount);
  134.            
  135.             mint(tokenAmount, msg.sender);
  136.            
  137.             return true;
  138.         }
  139.         else revert();
  140.     }
  141.    
  142.     function icoPurchase() internal onlyicoWhitelist returns(bool) {
  143.         uint256 tokenAmount = msg.value.div(ico.price);
  144.         uint256 tokensLeft = ico.cap.sub(ico.sold.add(tokenAmount));
  145.        
  146.         uint256 contributionCeiling = amountPerDay.mul((2 ** daysSinceLaunch));
  147.         uint256 personalCeiling = contributionCeiling.sub(amountContributedBy[msg.sender]);
  148.        
  149.         if (tokensLeft > 0 && personalCeiling > 0) {
  150.             wallet.send(this.value);
  151.            
  152.             ico.sold = ico.sold.add(tokenAmount);
  153.            
  154.             mint(tokenAmount, msg.sender);
  155.            
  156.             uint256 tokenLeftUntilClose = ico.cap.sub(ico.sold);
  157.             if (tokenLeftUntilClose <= 0) finishMinting();
  158.            
  159.             return true;
  160.         }
  161.         else revert();
  162.     }
  163.    
  164.     function addToPresaleWhitelist(address _a) internal onlyOwner returns(bool) {
  165.         presaleWhitelist[_a] = true;
  166.         return presaleWhitelist[_a];
  167.     }
  168.    
  169.     function addtoICOWhitelist(address _a) internal onlyOwner returns(bool) {
  170.         icoWhitelist[_a] = true;
  171.         return icoWhitelist[_a];
  172.     }
  173.    
  174.     function daysSinceLaunch() public view returns(uint256) {
  175.         return (now.sub(launchTime)) % UNIX_DAY;
  176.     }
  177. }
RAW Paste Data
Top