Ownable.sol 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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(
  11. address indexed previousOwner,
  12. address indexed newOwner
  13. );
  14. /**
  15. * @dev The Ownable constructor sets the original `owner` of the contract to the sender
  16. * account.
  17. */
  18. constructor() public {
  19. owner = msg.sender;
  20. }
  21. /**
  22. * @dev Throws if called by any account other than the owner.
  23. */
  24. modifier onlyOwner() {
  25. require(msg.sender == owner);
  26. _;
  27. }
  28. /**
  29. * @dev Allows the current owner to transfer control of the contract to a newOwner.
  30. * @param newOwner The address to transfer ownership to.
  31. */
  32. function transferOwnership(address newOwner) public onlyOwner {
  33. require(newOwner != address(0));
  34. emit OwnershipTransferred(owner, newOwner);
  35. owner = newOwner;
  36. }
  37. /**
  38. * @dev Allows the current owner to relinquish control of the contract.
  39. */
  40. function renounceOwnership() public onlyOwner {
  41. emit OwnershipRenounced(owner);
  42. owner = address(0);
  43. }
  44. }