github.com/SmartMeshFoundation/Spectrum@v0.0.0-20220621030607-452a266fee1e/contracts/statute/src/owned.sol (about) 1 pragma solidity >=0.5.0 <=0.5.3; 2 3 contract Owned { 4 5 /// `owner` is the only address that can call a function with this 6 /// modifier 7 modifier onlyOwner() { 8 require(msg.sender == owner); 9 _; 10 } 11 12 address public owner; 13 14 /// @notice The Constructor assigns the message sender to be `owner` 15 constructor() public { 16 owner = msg.sender; 17 } 18 19 address newOwner = address(0); 20 21 event OwnerUpdate(address _prevOwner, address _newOwner); 22 23 ///change the owner 24 function changeOwner(address _newOwner) public onlyOwner { 25 require(_newOwner != owner); 26 newOwner = _newOwner; 27 } 28 29 /// accept the ownership 30 function acceptOwnership() public { 31 require(msg.sender == newOwner); 32 emit OwnerUpdate(owner, newOwner); 33 owner = newOwner; 34 newOwner = address(0); 35 } 36 }