39 lines
1.1 KiB
Solidity
39 lines
1.1 KiB
Solidity
|
pragma solidity ^0.5.16;
|
||
|
|
||
|
|
||
|
// https://docs.synthetix.io/contracts/source/contracts/owned
|
||
|
contract Owned {
|
||
|
address public owner;
|
||
|
address public nominatedOwner;
|
||
|
|
||
|
constructor(address _owner) public {
|
||
|
require(_owner != address(0), "Owner address cannot be 0");
|
||
|
owner = _owner;
|
||
|
emit OwnerChanged(address(0), _owner);
|
||
|
}
|
||
|
|
||
|
function nominateNewOwner(address _owner) external onlyOwner {
|
||
|
nominatedOwner = _owner;
|
||
|
emit OwnerNominated(_owner);
|
||
|
}
|
||
|
|
||
|
function acceptOwnership() external {
|
||
|
require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership");
|
||
|
emit OwnerChanged(owner, nominatedOwner);
|
||
|
owner = nominatedOwner;
|
||
|
nominatedOwner = address(0);
|
||
|
}
|
||
|
|
||
|
modifier onlyOwner {
|
||
|
_onlyOwner();
|
||
|
_;
|
||
|
}
|
||
|
|
||
|
function _onlyOwner() private view {
|
||
|
require(msg.sender == owner, "Only the contract owner may perform this action");
|
||
|
}
|
||
|
|
||
|
event OwnerNominated(address newOwner);
|
||
|
event OwnerChanged(address oldOwner, address newOwner);
|
||
|
}
|