Skip to content

Instantly share code, notes, and snippets.

@Ultra-Tech-code
Last active August 8, 2022 09:59

Revisions

  1. Ultra-Tech-code renamed this gist Aug 8, 2022. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. Ultra-Tech-code created this gist Aug 1, 2022.
    26 changes: 26 additions & 0 deletions a timer for add and decrement
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    //SPDX-License-Identifier: MIT

    pragma solidity ^0.8.13;

    contract examole{
    uint count;

    uint timeframe = block.timestamp + 30 seconds;
    // uint timeframe;

    modifier timer{
    require(block.timestamp <= timeframe, "time has elapsed");
    _;
    }

    function add() public timer{
    count++;
    }

    function decrement() public timer{
    count--;
    }
    function getCount() public view returns(uint){
    return count;
    }
    }