Last active
August 23, 2018 13:23
-
-
Save devender-yadav/2cddc65d751e92f939fbd20a32af3868 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^ 0.4 .24; | |
// simple counter program | |
contract Counter{ | |
address public admin; | |
uint count; | |
constructor() public{ | |
count = 0; | |
admin = msg.sender; | |
} | |
function getCount() public view returns(uint _count){ | |
_count = count; | |
} | |
function incCounter() public { | |
require(msg.sender==admin, "only admin can increase counter"); | |
count++; | |
} | |
function decCounter() public { | |
require(msg.sender==admin, "only admin can increase counter"); | |
require(count>0, "Can't decrease if counter is equal to or less than 0"); | |
count--; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment