Ownable.sol 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. pragma solidity ^0.4.23;
  2. /**
  3. * @title Ownable
  4. * @dev The Ownable contract has an owner address, and provides basic authorization control
  5. * functions, this simplifies the implementation of "user permissions".
  6. */
  7. contract Ownable {
  8. address public owner;
  9. event OwnershipRenounced(address indexed previousOwner);
  10. event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
  11. /**
  12. * @dev The Ownable constructor sets the original `owner` of the contract to the sender
  13. * account.
  14. */
  15. constructor() public {
  16. owner = msg.sender;
  17. }
  18. /**
  19. * @dev Throws if called by any account other than the owner.
  20. */
  21. modifier onlyOwner() {
  22. require(msg.sender == owner);
  23. _;
  24. }
  25. /**
  26. * @dev Allows the current owner to transfer control of the contract to a newOwner.
  27. * @param newOwner The address to transfer ownership to.
  28. */
  29. function transferOwnership(address newOwner) public onlyOwner {
  30. require(newOwner != address(0));
  31. emit OwnershipTransferred(owner, newOwner);
  32. owner = newOwner;
  33. }
  34. /**
  35. * @dev Allows the current owner to relinquish control of the contract.
  36. */
  37. function renounceOwnership() public onlyOwner {
  38. emit OwnershipRenounced(owner);
  39. owner = address(0);
  40. }
  41. }