Last active
May 14, 2021 05:42
-
-
Save percybolmer/e49779fb0057d0797517d7a8790dd443 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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.4; | |
/** | |
* @notice Contract is a inheritable smart contract that will add a | |
* New modifier called onlyOwner available in the smart contract inherting it | |
* | |
* onlyOwner makes a function only callable from the Token owner | |
* | |
*/ | |
contract Ownable { | |
// _owner is the owner of the Token | |
address private _owner; | |
/** | |
* Event OwnershipTransferred is used to log that a ownership change of the token has occured | |
*/ | |
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); | |
/** | |
* Modifier | |
* We create our own function modifier called onlyOwner, it will Require the current owner to be | |
* the same as msg.sender | |
*/ | |
modifier onlyOwner() { | |
require(_owner == msg.sender, "Ownable: only owner can call this function"); | |
// This _; is not a TYPO, It is important for the compiler; | |
_; | |
} | |
constructor() { | |
_owner = msg.sender; | |
emit OwnershipTransferred(address(0), _owner); | |
} | |
/** | |
* @notice owner() returns the currently assigned owner of the Token | |
* | |
*/ | |
function owner() public view returns(address) { | |
return _owner; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment