Advertisement
Guest User

Untitled

a guest
Feb 14th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. pragma solidity ^0.4.18;
  2.  
  3. contract Core {
  4. address public owner;
  5.  
  6. event OwnerShipOfServiceChange(address newAdress, uint transaction);
  7.  
  8. uint public fixedAmount = 1 ether;
  9. uint public fixedtime = 2 minutes;
  10. uint public lastTransaction = 0;
  11.  
  12. uint public oneHour = 60 minutes;
  13. uint public maxEthers = 5 ether;
  14. uint public lastWidraw = 0;
  15.  
  16. modifier ownerOnly{require(msg.sender == owner);_;}
  17.  
  18. modifier isAllowedToWidraw(uint amount){
  19. require(amount<maxEthers);
  20. require(now - lastWidraw >= oneHour);
  21. _;
  22. }
  23.  
  24. function Core() payable public {
  25. owner = msg.sender;
  26. }
  27.  
  28. function checkIfPositive(uint amount) private pure returns (bool isPositive){
  29. return amount > 0 ? true : false;
  30. }
  31.  
  32. function() payable public{}
  33.  
  34. function getBalance() public view returns(uint,uint){
  35. return (this.balance,msg.sender.balance);
  36. }
  37.  
  38. function withDraw(uint money) public ownerOnly isAllowedToWidraw(money){
  39. owner.transfer(money);
  40. lastWidraw = now;
  41. }
  42.  
  43. function buyService()public payable{
  44. uint diff = msg.value - fixedAmount;
  45. bool isPositive = checkIfPositive(diff);
  46. if(isPositive){
  47. msg.sender.transfer(diff);
  48. }
  49.  
  50. lastTransaction = now;
  51. OwnerShipOfServiceChange(msg.sender, lastTransaction);
  52. }
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement