Guest User

Untitled

a guest
Aug 17th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. pragma solidity ^0.4.22;
  2.  
  3. contract Iotether{
  4. address owner;
  5. uint limit;
  6. uint fee_per_second;
  7. constructor() public{
  8. owner = msg.sender;
  9. limit = 0;
  10. }
  11.  
  12. event onGpio(uint pin, uint limit);
  13.  
  14. function changeFee(uint price_per_second) public {
  15. require(owner == msg.sender, "Solo propietario");
  16. fee_per_second = price_per_second;
  17. }
  18.  
  19. function getLimit() public view returns (uint) {
  20. return limit;
  21. }
  22.  
  23. function SwitchOn() public payable{
  24. uint sec;
  25. sec = msg.value/fee_per_second;
  26. if (limit < block.timestamp){
  27. limit = block.timestamp+sec;
  28. }else{
  29. limit = limit + sec;
  30. }
  31. emit onGpio(1, limit);
  32. }
  33.  
  34. }
Add Comment
Please, Sign In to add comment