Last active
August 8, 2022 20:53
-
-
Save vdparikh/eec9045458084f2abfd2f3f8383094a2 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: UNLICENSED | |
pragma solidity 0.8.11; | |
contract Onwership { | |
address public owner; | |
modifier onlyOwner { | |
require(owner == msg.sender, "You are not the owner"); | |
_; | |
} | |
constructor() { | |
owner = msg.sender; | |
} | |
function sayHello() public view returns (string memory) { | |
if (msg.sender == owner) { | |
return "Hello owner!"; | |
} else { | |
return "Hello world!"; | |
} | |
} | |
function changeOwnership(address _newOwner) public onlyOwner returns (bool result) { | |
// function changeOwnership(address _newOwner) public{ | |
require(owner == msg.sender, "You are not the owner"); | |
owner = _newOwner; | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment