Skip to content

Instantly share code, notes, and snippets.

@vdparikh
Last active August 8, 2022 20:53
Show Gist options
  • Save vdparikh/eec9045458084f2abfd2f3f8383094a2 to your computer and use it in GitHub Desktop.
Save vdparikh/eec9045458084f2abfd2f3f8383094a2 to your computer and use it in GitHub Desktop.
// 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