Skip to content

Latest commit

 

History

History
237 lines (190 loc) · 6.48 KB

Ownable.md

File metadata and controls

237 lines (190 loc) · 6.48 KB

Ownable.sol

View Source: contracts/Dependencies/Ownable.sol

↘ Derived Contracts: ActivePoolStorage, BorrowerOperationsStorage, CollSurplusPoolStorage, DefaultPoolStorage, FeeDistributorStorage, HintHelpersStorage, IMasset, LiquityBaseParams, MultiTroveGetterStorage, NueToken, PriceFeedStorage, Proxy, SortedTrovesStorage, StabilityPoolStorage, TroveManagerStorage, ZUSDToken

Ownable

Contract module which provides a basic access control mechanism, where there is an account (an owner) that can be granted exclusive access to specific functions. This module is used through inheritance. It will make available the modifier onlyOwner, which can be applied to your functions to restrict their use to the owner.

Contract Members

Constants & Variables

bytes32 private constant KEY_OWNER;

Events

event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

Modifiers

onlyOwner

Throws if called by any account other than the owner.

modifier onlyOwner() internal

Functions


constructor

Initializes the contract setting the deployer as the initial owner.

function () internal nonpayable
Source Code
constructor () internal {
        _setOwner(msg.sender);
    }

_setOwner

Set address of the owner.

function _setOwner(address _owner) internal nonpayable

Arguments

Name Type Description
_owner address Address of the owner.
Source Code
function _setOwner(address _owner) internal {
        require(_owner != address(0), "Ownable::setOwner: invalid address");
        emit OwnershipTransferred(getOwner(), _owner);

        bytes32 key = KEY_OWNER;
        assembly {
            sstore(key, _owner)
        }
    }

setOwner

Set address of the owner (only owner can call this function)

function setOwner(address _owner) public nonpayable onlyOwner 

Arguments

Name Type Description
_owner address Address of the owner.
Source Code
function setOwner(address _owner) public onlyOwner {
        _setOwner(_owner);
    }

getOwner

Return address of the owner.

function getOwner() public view
returns(_owner address)
Source Code
function getOwner() public view returns (address _owner) {
        bytes32 key = KEY_OWNER;
        assembly {
            _owner := sload(key)
        }
    }

Contracts