Skip to content

Instantly share code, notes, and snippets.

@TehilaFavourite
Created May 10, 2023 14:29
Show Gist options
  • Save TehilaFavourite/1a4dbdd3d8c0cba82056bd034a2aa6e8 to your computer and use it in GitHub Desktop.
Save TehilaFavourite/1a4dbdd3d8c0cba82056bd034a2aa6e8 to your computer and use it in GitHub Desktop.
pragma solidity 0.8.19;
contract myModifier {
address public owner;
uint public myNumber;
modifier onlyOwner {
require(msg.sender == owner, "Only contract owner can call this function");
_; // This indicates where the function body will be placed
}
modifier validNumber {
require(myNumber > 0, "Number must be greater than zero");
_;
}
constructor() {
owner = msg.sender;
myNumber = 0;
}
function setNumber(uint _number) public onlyOwner validNumber {
myNumber = _number;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment