Skip to content

Instantly share code, notes, and snippets.

@bartubozkurt
Last active February 1, 2023 16:09
Show Gist options
  • Save bartubozkurt/68f89f02f05637b46e87a3084ac0ac0f to your computer and use it in GitHub Desktop.
Save bartubozkurt/68f89f02f05637b46e87a3084ac0ac0f to your computer and use it in GitHub Desktop.
/* 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