Skip to content

Instantly share code, notes, and snippets.

@MCarlomagno
Created October 14, 2021 20:00
Show Gist options
  • Save MCarlomagno/448f50cb97a31d8c3beff0dc7849e397 to your computer and use it in GitHub Desktop.
Save MCarlomagno/448f50cb97a31d8c3beff0dc7849e397 to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract Owner {
address private owner;
event OwnerSet(address indexed oldOwner, address indexed newOwner);
modifier isOwner() {
require(msg.sender == owner, "Caller is not owner");
_;
}
constructor() {
owner = msg.sender;
emit OwnerSet(address(0), owner);
}
function changeOwner(address newOwner) public isOwner {
emit OwnerSet(owner, newOwner);
owner = newOwner;
}
function getOwner() external view returns (address) {
return owner;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment