Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. pragma solidity ^0.5.5;
  2.  
  3. /**
  4. * @title Ownable
  5. * @dev The Ownable contract has an owner address, and provides basic authorization control
  6. * functions, this simplifies the implementation of "user permissions".
  7. */
  8. contract Ownable {
  9. address payable private _owner;
  10.  
  11. event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
  12.  
  13. /**
  14. * @dev The Ownable constructor sets the original `owner` of the contract to the sender
  15. * account.
  16. */
  17. constructor() internal {
  18. _owner = msg.sender;
  19. emit OwnershipTransferred(address(0), _owner);
  20. }
  21.  
  22. /**
  23. * @return the address of the owner.
  24. */
  25. function owner() public view returns(address payable) {
  26. return _owner;
  27. }
  28.  
  29. /**
  30. * @dev Throws if called by any account other than the owner.
  31. */
  32. modifier onlyOwner() {
  33. require(isOwner());
  34. _;
  35. }
  36.  
  37. /**
  38. * @return true if `msg.sender` is the owner of the contract.
  39. */
  40. function isOwner() public view returns(bool) {
  41. return msg.sender == _owner;
  42. }
  43.  
  44. /**
  45. * @dev Allows the current owner to relinquish control of the contract.
  46. * @notice Renouncing to ownership will leave the contract without an owner.
  47. * It will not be possible to call the functions with the `onlyOwner`
  48. * modifier anymore.
  49. */
  50. function renounceOwnership() public onlyOwner {
  51. emit OwnershipTransferred(_owner, address(0));
  52. _owner = address(0);
  53. }
  54.  
  55. /**
  56. * @dev Allows the current owner to transfer control of the contract to a newOwner.
  57. * @param newOwner The address to transfer ownership to.
  58. */
  59. function transferOwnership(address payable newOwner) public onlyOwner {
  60. _transferOwnership(newOwner);
  61. }
  62.  
  63. /**
  64. * @dev Transfers control of the contract to a newOwner.
  65. * @param newOwner The address to transfer ownership to.
  66. */
  67. function _transferOwnership(address payable newOwner) internal {
  68. require(newOwner != address(0));
  69. emit OwnershipTransferred(_owner, newOwner);
  70. _owner = newOwner;
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement