Created
May 10, 2023 14:29
-
-
Save TehilaFavourite/1a4dbdd3d8c0cba82056bd034a2aa6e8 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.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