Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pragma solidity ^0.4.22;
- contract Iotether{
- address owner;
- uint limit;
- uint fee_per_second;
- constructor() public{
- owner = msg.sender;
- limit = 0;
- }
- event onGpio(uint pin, uint limit);
- function changeFee(uint price_per_second) public {
- require(owner == msg.sender, "Solo propietario");
- fee_per_second = price_per_second;
- }
- function getLimit() public view returns (uint) {
- return limit;
- }
- function SwitchOn() public payable{
- uint sec;
- sec = msg.value/fee_per_second;
- if (limit < block.timestamp){
- limit = block.timestamp+sec;
- }else{
- limit = limit + sec;
- }
- emit onGpio(1, limit);
- }
- }
Add Comment
Please, Sign In to add comment