-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathOwnable.sol
34 lines (27 loc) · 896 Bytes
/
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
// Main Ownable contract
pragma solidity ^0.6.5;
pragma experimental ABIEncoderV2;
abstract contract Ownable {
modifier onlyOwner {
require(msg.sender == owner, "O: onlyOwner function!");
_;
}
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @notice Initializes owner variable with msg.sender address.
*/
constructor() internal {
owner = msg.sender;
emit OwnershipTransferred(address(0), msg.sender);
}
/**
* @notice Transfers ownership to the desired address.
* The function is callable only by the owner.
*/
function transferOwnership(address _owner) external onlyOwner {
require(_owner != address(0), "O: new owner is the zero address!");
emit OwnershipTransferred(owner, _owner);
owner = _owner;
}
}