-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ownable.sol
46 lines (38 loc) · 1.13 KB
/
Ownable.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
contract Ownable {
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
address private _owner;
modifier onlyOwner() {
require(
_owner == msg.sender,
"Ownable: only onwer can call this function."
);
_;
}
constructor() {
_owner = msg.sender;
emit OwnershipTransferred(address(0), _owner);
}
function owner() public view returns (address) {
return _owner;
}
function renounceOwnership() public onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
function transferOwnership(address newOwner) public onlyOwner {
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal onlyOwner {
require(
newOwner != address(0),
"Ownable: new oner can't be the rezo address"
);
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}