Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.31 KB | None | 0 0
  1. pragma solidity ^0.4.19;
  2.  
  3. /**
  4. * Welcome to the Telegram chat https://devsolidity.io/
  5. *
  6. * Devloped by hirama & zhooq & nexenta
  7. */
  8.  
  9. library SafeMath {
  10. function mul(uint256 a, uint256 b) internal constant returns (uint256) {
  11. uint256 c = a * b;
  12. assert(a == 0 || c / a == b);
  13. return c;
  14. }
  15.  
  16. function div(uint256 a, uint256 b) internal constant returns (uint256) {
  17. uint256 c = a / b;
  18. return c;
  19. }
  20.  
  21. function sub(uint256 a, uint256 b) internal constant returns (uint256) {
  22. assert(b <= a);
  23. return a - b;
  24. }
  25.  
  26. function add(uint256 a, uint256 b) internal constant returns (uint256) {
  27. uint256 c = a + b;
  28. assert(c >= a);
  29. return c;
  30. }
  31. }
  32.  
  33. contract Token {
  34. uint256 public totalSupply;
  35. function balanceOf(address who) public constant returns (uint256);
  36. function transfer(address to, uint256 value) public returns (bool);
  37. function allowance(address owner, address spender) public constant returns (uint256);
  38. function transferFrom(address from, address to, uint256 value) public returns (bool);
  39. function approve(address spender, uint256 value) public returns (bool);
  40. event Transfer(address indexed from, address indexed to, uint256 value);
  41. event Approval(address indexed owner, address indexed spender, uint256 value);
  42. }
  43.  
  44. /**
  45. * @title Ownable
  46. * @dev The Ownable contract has an owner address, and provides basic authorization control
  47. * functions, this simplifies the implementation of "user permissions".
  48. */
  49. contract Ownable {
  50. address public owner;
  51.  
  52. /**
  53. * @dev The Ownable constructor sets the original `owner` of the contract to the sender
  54. * account.
  55. */
  56. function Ownable() public {
  57. owner = msg.sender;
  58. }
  59.  
  60. /**
  61. * @dev Throws if called by any account other than the owner.
  62. */
  63. modifier onlyOwner() {
  64. require(msg.sender == owner);
  65. _;
  66. }
  67.  
  68. /**
  69. * @dev Allows the current owner to transfer control of the contract to a newOwner.
  70. * @param newOwner The address to transfer ownership to.
  71. */
  72. function transferOwnership(address newOwner) onlyOwner public {
  73. require(newOwner != address(0));
  74. owner = newOwner;
  75. }
  76. }
  77.  
  78. contract Pausable is Ownable {
  79.  
  80. uint public constant startPreICO = 1517443200; // 1'st February
  81. uint public constant endPreICO = startPreICO + 14 days;
  82.  
  83. uint public constant startICOStage1 = endPreICO;
  84. uint public constant endICOStage1 = startICOStage1 + 21 days;
  85.  
  86. uint public constant startICOStage2 = endICOStage1;
  87. uint public constant endICOStage2 = startICOStage2 + 21 days;
  88.  
  89. uint public constant startICOStage3 = endICOStage2;
  90. uint public constant endICOStage3 = endICOStage2 + 21 days;
  91.  
  92. uint public constant startICOStage4 = endICOStage3;
  93. uint public constant endICOStage4 = startICOStage4 + 21 days;
  94.  
  95. uint public constant startICOStage5 = endICOStage4;
  96. uint public endICOStage5 = startICOStage5 + 21 days;
  97.  
  98. /**
  99. * @dev modifier to allow actions only when the contract IS not paused
  100. */
  101. modifier whenNotPaused() {
  102. require(now < startPreICO || now > endICOStage5);
  103. _;
  104. }
  105.  
  106. }
  107.  
  108. contract StandardToken is Token, Pausable {
  109. using SafeMath for uint256;
  110. mapping (address => mapping (address => uint256)) internal allowed;
  111.  
  112. mapping(address => uint256) balances;
  113.  
  114. /**
  115. * @dev transfer token for a specified address
  116. * @param _to The address to transfer to.
  117. * @param _value The amount to be transferred.
  118. */
  119. function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) {
  120. require(_to != address(0));
  121. balances[msg.sender] = balances[msg.sender].sub(_value);
  122. balances[_to] = balances[_to].add(_value);
  123. Transfer(msg.sender, _to, _value);
  124. return true;
  125. }
  126.  
  127. /**
  128. * @dev Gets the balance of the specified address.
  129. * @param _owner The address to query the the balance of.
  130. * @return An uint256 representing the amount owned by the passed address.
  131. */
  132. function balanceOf(address _owner) public constant returns (uint256 balance) {
  133. return balances[_owner];
  134. }
  135.  
  136. /**
  137. * @dev Transfer tokens from one address to another
  138. * @param _from address The address which you want to send tokens from
  139. * @param _to address The address which you want to transfer to
  140. * @param _value uint256 the amount of tokens to be transferred
  141. */
  142. function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) {
  143. require(_to != address(0));
  144. require(_value <= allowed[_from][msg.sender]);
  145.  
  146. balances[_from] = balances[_from].sub(_value);
  147. balances[_to] = balances[_to].add(_value);
  148. allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
  149. Transfer(_from, _to, _value);
  150. return true;
  151. }
  152.  
  153. /**
  154. * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
  155. *
  156. * Beware that changing an allowance with this method brings the risk that someone may use both the old
  157. * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
  158. * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
  159. * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
  160. * @param _spender The address which will spend the funds.
  161. * @param _value The amount of tokens to be spent.
  162. */
  163. function approve(address _spender, uint256 _value) public returns (bool) {
  164. allowed[msg.sender][_spender] = _value;
  165. Approval(msg.sender, _spender, _value);
  166. return true;
  167. }
  168.  
  169. /**
  170. * @dev Function to check the amount of tokens that an owner allowed to a spender.
  171. * @param _owner address The address which owns the funds.
  172. * @param _spender address The address which will spend the funds.
  173. * @return A uint256 specifying the amount of tokens still available for the spender.
  174. */
  175. function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
  176. return allowed[_owner][_spender];
  177. }
  178.  
  179. /**
  180. * approve should be called when allowed[_spender] == 0. To increment
  181. * allowed value is better to use this function to avoid 2 calls (and wait until
  182. * the first transaction is mined)
  183. * From MonolithDAO Token.sol
  184. */
  185. function increaseApproval (address _spender, uint _addedValue) public returns (bool success) {
  186. allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
  187. Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
  188. return true;
  189. }
  190.  
  191. function decreaseApproval (address _spender, uint _subtractedValue) public returns (bool success) {
  192. uint oldValue = allowed[msg.sender][_spender];
  193. if (_subtractedValue > oldValue) {
  194. allowed[msg.sender][_spender] = 0;
  195. } else {
  196. allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
  197. }
  198. Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
  199. return true;
  200. }
  201. }
  202.  
  203. /**
  204. * @title Burnable Token
  205. * @dev Token that can be irreversibly burned (destroyed).
  206. */
  207. contract BurnableToken is StandardToken {
  208.  
  209. event Burn(address indexed burner, uint256 value);
  210.  
  211. /**
  212. * @dev Burns a specific amount of tokens.
  213. * @param _value The amount of token to be burned.
  214. */
  215. function burn(uint256 _value) public {
  216. require(_value > 0);
  217. require(_value <= balances[msg.sender]);
  218.  
  219. address burner = msg.sender;
  220. balances[burner] = balances[burner].sub(_value);
  221. totalSupply = totalSupply.sub(_value);
  222. Burn(burner, _value);
  223. }
  224. }
  225.  
  226. contract MBEToken is BurnableToken {
  227. string public constant name = "MoBee";
  228. string public constant symbol = "MBE";
  229. uint8 public constant decimals = 18;
  230. address public tokenWallet;
  231. address public founderWallet;
  232. address public bountyWallet;
  233. uint public currentFundrise = 0;
  234. uint public raisedEthers = 0;
  235.  
  236. uint public constant INITIAL_SUPPLY = 20000000 ether;
  237.  
  238. uint256 constant THOUSAND = 1000;
  239. uint256 constant TEN_THOUSAND = 10000;
  240. uint public tokenRate = THOUSAND.div(9); // tokens per 1 ether ( 1 ETH / 0.009 ETH = 111.11 MBE )
  241. uint public tokenRate70 = tokenRate.mul(100).div(30); // tokens per 1 ether with 70% discount
  242. uint public tokenRate50 = tokenRate.mul(100).div(50); // tokens per 1 ether with 50% discount
  243. uint public tokenRate40 = tokenRate.mul(100).div(60); // tokens per 1 ether with 40% discount
  244. uint public tokenRate20 = tokenRate.mul(100).div(80); // tokens per 1 ether with 20% discount
  245. uint public tokenRate10 = tokenRate.mul(100).div(90); // tokens per 1 ether with 10% discount
  246.  
  247. /**
  248. * @dev Constructor that gives msg.sender all of existing tokens.
  249. */
  250. function MBEToken(address tokenOwner, address founder, address bounty) {
  251. totalSupply = INITIAL_SUPPLY;
  252. balances[tokenOwner] = INITIAL_SUPPLY / 100 * 85;
  253. balances[founder] = INITIAL_SUPPLY / 100 * 10;
  254. balances[bounty] = INITIAL_SUPPLY / 100 * 5;
  255. tokenWallet = tokenOwner;
  256. founderWallet = founder;
  257. bountyWallet = bounty;
  258. }
  259.  
  260. function setupTokenRate(uint newTokenRate) {
  261. tokenRate = newTokenRate;
  262. tokenRate70 = tokenRate.mul(100).div(30); // tokens per 1 ether with 70% discount
  263. tokenRate50 = tokenRate.mul(100).div(50); // tokens per 1 ether with 50% discount
  264. tokenRate40 = tokenRate.mul(100).div(60); // tokens per 1 ether with 40% discount
  265. tokenRate20 = tokenRate.mul(100).div(80); // tokens per 1 ether with 20% discount
  266. tokenRate10 = tokenRate.mul(100).div(90); // tokens per 1 ether with 10% discount
  267. }
  268.  
  269. function setupFinal(uint finalDate) public onlyOwner returns(bool) {
  270. endICOStage5 = finalDate;
  271. return true;
  272. }
  273.  
  274. function sellManually(address _to, uint amount) public onlyOwner returns(bool) {
  275. buyTokens(_to, amount);
  276. return true;
  277. }
  278.  
  279. function () payable public {
  280. if (!isTokenSale()) revert();
  281. buyTokens(msg.sender, msg.value);
  282. }
  283.  
  284. function isTokenSale() internal returns (bool) {
  285. if (now >= startPreICO && now < endICOStage5) {
  286. return true;
  287. } else {
  288. return false;
  289. }
  290. }
  291.  
  292. function buyTokens(address _to, uint amount) internal {
  293. uint rate = extraRate(amount, tokenRate);
  294. uint tokens = amount.mul(rate);
  295. if (now >= startPreICO && now < endPreICO) {
  296. rate = extraRate(amount, tokenRate70);
  297. tokens = amount.mul(rate);
  298. safeSend(tokens);
  299. } else if (now >= startICOStage1 && now < endICOStage1) {
  300. rate = extraRate(amount, tokenRate50);
  301. tokens = amount.mul(rate);
  302. safeSend(tokens);
  303. } else if (now >= startICOStage2 && now < endICOStage2) {
  304. rate = extraRate(amount, tokenRate40);
  305. tokens = amount.mul(rate);
  306. safeSend(tokens);
  307. } else if (now >= startICOStage3 && now < endICOStage3) {
  308. rate = extraRate(amount, tokenRate20);
  309. tokens = amount.mul(rate);
  310. safeSend(tokens);
  311. } else if (now >= startICOStage4 && now < endICOStage4) {
  312. rate = extraRate(amount, tokenRate10);
  313. tokens = amount.mul(rate);
  314. safeSend(tokens);
  315. } else if (now >= startICOStage5 && now < endICOStage5) {
  316. safeSend(tokens);
  317. }
  318. }
  319.  
  320. function extraRate(uint amount, uint rate) internal returns(uint) {
  321. return ( ( rate * 10 ** 20 ) / ( 100 - extraDiscount(amount) ) ) / ( 10 ** 18 );
  322. }
  323.  
  324. function extraDiscount(uint amount) internal returns(uint) {
  325. if ( 3 ether <= amount && amount <= 5 ether ) {
  326. return 5;
  327. } else if ( 5 ether < amount && amount <= 10 ether ) {
  328. return 7;
  329. } else if ( 10 ether < amount && amount <= 20 ether ) {
  330. return 10;
  331. } else if ( 20 ether < amount ) {
  332. return 15;
  333. }
  334. return 0;
  335. }
  336.  
  337. function safeSend(uint tokens) internal {
  338. uint256 balance = balanceOf(owner);
  339. if (balance < tokens) {
  340. uint toReturn = tokenRate.mul(tokens.sub(balance));
  341. sendTokens(msg.sender, balance);
  342. msg.sender.transfer(toReturn);
  343. founderWallet.transfer(msg.value.sub(toReturn));
  344. raisedEthers += msg.value.sub(toReturn);
  345. } else {
  346. sendTokens(msg.sender, tokens);
  347. founderWallet.transfer(msg.value);
  348. raisedEthers += msg.value;
  349. }
  350. }
  351.  
  352. function sendTokens(address _to, uint tokens) internal {
  353. balances[owner] = balances[owner].sub(tokens);
  354. balances[_to] += tokens;
  355. Transfer(owner, _to, tokens);
  356. currentFundrise += tokens;
  357. }
  358. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement