Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Ownable2Step

Inherits: Ownable

Contract module which provides access control mechanism, where there is an account (an owner) that can be granted exclusive access to specific functions. This extension of the {Ownable} contract includes a two-step mechanism to transfer ownership, where the new owner must call {acceptOwnership} in order to replace the old one. This can help prevent common mistakes, such as transfers of ownership to incorrect accounts, or to contracts that are unable to interact with the permission system. The initial owner is specified at deployment time in the constructor for Ownable. This can later be changed with {transferOwnership} and {acceptOwnership}. This module is used through inheritance. It will make available all functions from parent (Ownable).

State Variables

_pendingOwner

address private _pendingOwner;

Functions

pendingOwner

Returns the address of the pending owner.

function pendingOwner() public view virtual returns (address);

transferOwnership

Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner. Setting newOwner to the zero address is allowed; this can be used to cancel an initiated ownership transfer.

function transferOwnership(address newOwner) public virtual override onlyOwner;

_transferOwnership

Transfers ownership of the contract to a new account (newOwner) and deletes any pending owner. Internal function without access restriction.

function _transferOwnership(address newOwner) internal virtual override;

acceptOwnership

The new owner accepts the ownership transfer.

function acceptOwnership() public virtual;

Events

OwnershipTransferStarted

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