Last active
February 1, 2023 16:09
-
-
Save bartubozkurt/68f89f02f05637b46e87a3084ac0ac0f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* Bad */ | |
address owner; | |
function setOwner() public { | |
owner = msg.sender; | |
} | |
/* Better */ | |
contract Buggy{ | |
/* | |
modifier onlyOwner() { | |
require(_owner == _msgSender(), "Ownable: caller is not the owner"); | |
_; | |
} | |
*/ | |
address owner; | |
function set_protected() public onlyOwner(){ | |
owner = msg.sender; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment