Skip to content

Instantly share code, notes, and snippets.

@devender-yadav
Last active August 23, 2018 13:23
Show Gist options
  • Save devender-yadav/2cddc65d751e92f939fbd20a32af3868 to your computer and use it in GitHub Desktop.
Save devender-yadav/2cddc65d751e92f939fbd20a32af3868 to your computer and use it in GitHub Desktop.
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