A 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.
The owner account is set through ownership transfer. This module makes it possible to transfer the ownership of the contract to a new account in one step, as well as to an interim pending owner. In the second flow the ownership does not change until the pending owner accepts the ownership transfer.
bytes32 _OWNER_SLOT
bytes32 _OWNERSHIP_TRANSFER_SLOT
constructor(address _owner) internal
Initializes the contract by transferring ownership to the owner parameter.
Name | Type | Description |
---|---|---|
_owner | address | Address to set as the initial owner of the contract |
modifier onlyOwner()
Modifier that throws an error if called by any account other than the owner.
function owner() public view returns (address owner_)
Returns the current owner of the contract.
Name | Type | Description |
---|---|---|
owner_ | address | The current owner of the contract |
function pendingOwner() public view returns (address owner_)
Returns the pending owner of the contract.
Name | Type | Description |
---|---|---|
owner_ | address | The pending owner of the contract |
function transferOwnership(address newOwner) external virtual
Transfers ownership of the contract to a new account newOwner
.
Can only be called by the current owner.
Name | Type | Description |
---|---|---|
newOwner | address | The address to transfer ownership to |
function proposeOwnership(address newOwner) external virtual
Propose to transfer ownership of the contract to a new account newOwner
.
Can only be called by the current owner. The ownership does not change until the new owner accepts the ownership transfer.
Name | Type | Description |
---|---|---|
newOwner | address | The address to transfer ownership to |
function acceptOwnership() external virtual
Accepts ownership of the contract.
Can only be called by the pending owner
function _transferOwnership(address newOwner) internal virtual
Internal function to transfer ownership of the contract to a new account newOwner
.
Called in the constructor to set the initial owner.
Name | Type | Description |
---|---|---|
newOwner | address | The address to transfer ownership to |