Created
June 29, 2023 23:57
-
-
Save TehilaFavourite/178535d2ceb93dba13f9b4a53903e83b 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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8.0; | |
contract OwnedContract { | |
address public owner; | |
constructor() { | |
owner = msg.sender; | |
} | |
modifier onlyOwner() { | |
require(msg.sender == owner, "Only the contract owner can call this function."); | |
_; | |
} | |
function transferOwnership(address newOwner) external onlyOwner { | |
require(newOwner != address(0), "Invalid address."); | |
owner = newOwner; | |
} | |
// Example function only callable by the contract owner | |
function doSomething() external onlyOwner { | |
// Perform some privileged operation | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment