Skip to main content

LSP14Ownable2Step

Standard Specifications
Solidity implementation

LSP14Ownable2Step

This contract is a modified version of the OwnableUnset.sol implementation, where transferring and renouncing ownership works as a 2-step process. This can be used as a confirmation mechanism to prevent potential mistakes when transferring ownership of the contract, where the control of the contract could be lost forever. (e.g: providing the wrong address as a parameter to the function, transferring ownership to an EOA for which the user lost its private key, etc...)

Public Methods​

Public methods are accessible externally from users, allowing interaction with this function from dApps or other smart contracts. When marked as 'public', a method can be called both externally and internally, on the other hand, when marked as 'external', a method can only be called externally.

RENOUNCE_OWNERSHIP_CONFIRMATION_DELAY​

References
function RENOUNCE_OWNERSHIP_CONFIRMATION_DELAY()
external
view
returns (uint256);

The number of block that MUST pass before one is able to confirm renouncing ownership.

Returns​

NameTypeDescription
0uint256Number of blocks.

RENOUNCE_OWNERSHIP_CONFIRMATION_PERIOD​

References
function RENOUNCE_OWNERSHIP_CONFIRMATION_PERIOD()
external
view
returns (uint256);

The number of blocks during which one can renounce ownership.

Returns​

NameTypeDescription
0uint256Number of blocks.

acceptOwnership​

References
function acceptOwnership() external nonpayable;

msg.sender is accepting ownership of contract: address(this).

Transfer ownership of the contract from the current owner() to the pendingOwner(). Once this function is called:

Requirements:


owner​

References
function owner() external view returns (address);

Returns the address of the current owner.

Returns​

NameTypeDescription
0address-

pendingOwner​

References
info

If no ownership transfer is in progress, the pendingOwner will be address(0)..

function pendingOwner() external view returns (address);

The address that ownership of the contract is transferred to. This address may use acceptOwnership() to gain ownership of the contract.

Returns​

NameTypeDescription
0address-

renounceOwnership​

References
danger

Leaves the contract without an owner. Once ownership of the contract has been renounced, any function that is restricted to be called only by the owner will be permanently inaccessible, making these functions not callable anymore and unusable.

function renounceOwnership() external nonpayable;

msg.sender is renouncing ownership of contract address(this).

Renounce ownership of the contract in a 2-step process.

  1. The first call will initiate the process of renouncing ownership.

  2. The second call is used as a confirmation and will leave the contract without an owner.


transferOwnership​

References
function transferOwnership(address newOwner) external nonpayable;

Transfer ownership initiated by newOwner.

Initiate the process of transferring ownership of the contract by setting the new owner as the pending owner. If the new owner is a contract that supports + implements LSP1, this will also attempt to notify the new owner that ownership has been transferred to them by calling the universalReceiver() function on the newOwner contract.

Requirements:

  • newOwner cannot accept ownership of the contract in the same transaction. (For instance, via a callback from its universalReceiver(...) function).

Parameters​

NameTypeDescription
newOwneraddressThe address of the new owner.

Internal Methods​

Any method labeled as internal serves as utility function within the contract. They can be used when writing solidity contracts that inherit from this contract. These methods can be extended or modified by overriding their internal behavior to suit specific needs.

Internal functions cannot be called externally, whether from other smart contracts, dApp interfaces, or backend services. Their restricted accessibility ensures that they remain exclusively available within the context of the current contract, promoting controlled and encapsulated usage of these internal utilities.

_checkOwner​

function _checkOwner() internal view;

Throws if the sender is not the owner.


_setOwner​

function _setOwner(address newOwner) internal nonpayable;

Changes the owner if newOwner and oldOwner are different This pattern is useful in inheritance.


_transferOwnership​

function _transferOwnership(address newOwner) internal nonpayable;

Set the pending owner of the contract and cancel any renounce ownership process that was previously started.

Requirements:

  • newOwner cannot be the address of the contract itself.

Parameters​

NameTypeDescription
newOwneraddressThe address of the new pending owner.

_acceptOwnership​

function _acceptOwnership() internal nonpayable;

Set the pending owner of the contract as the new owner.


_renounceOwnership​

function _renounceOwnership() internal nonpayable;

Initiate or confirm the process of renouncing ownership after a specific delay of blocks have passed.


Events​

OwnershipRenounced​

References
  • Specification details: LSP-14-Ownable2Step
  • Solidity implementation: LSP14Ownable2Step.sol
  • Event signature: OwnershipRenounced()
  • Event topic hash: 0xd1f66c3d2bc1993a86be5e3d33709d98f0442381befcedd29f578b9b2506b1ce
event OwnershipRenounced();

Successfully renounced ownership of the contract. This contract is now owned by anyone, it's owner is address(0).

Emitted when the ownership of the contract has been renounced.


OwnershipTransferStarted​

References
  • Specification details: LSP-14-Ownable2Step
  • Solidity implementation: LSP14Ownable2Step.sol
  • Event signature: OwnershipTransferStarted(address,address)
  • Event topic hash: 0x38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e22700
event OwnershipTransferStarted(
address indexed previousOwner,
address indexed newOwner
);

The transfer of ownership of the contract was initiated. Pending new owner set to: newOwner.

Emitted when transferOwnership(..) was called and the first step of transferring ownership completed successfully which leads to pendingOwner being updated.

Parameters​

NameTypeDescription
previousOwner indexedaddressThe address of the previous owner.
newOwner indexedaddressThe address of the new owner.

OwnershipTransferred​

References
  • Specification details: LSP-14-Ownable2Step
  • Solidity implementation: LSP14Ownable2Step.sol
  • Event signature: OwnershipTransferred(address,address)
  • Event topic hash: 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);

Parameters​

NameTypeDescription
previousOwner indexedaddress-
newOwner indexedaddress-

RenounceOwnershipStarted​

References
  • Specification details: LSP-14-Ownable2Step
  • Solidity implementation: LSP14Ownable2Step.sol
  • Event signature: RenounceOwnershipStarted()
  • Event topic hash: 0x81b7f830f1f0084db6497c486cbe6974c86488dcc4e3738eab94ab6d6b1653e7
event RenounceOwnershipStarted();

Ownership renouncement initiated.

Emitted when starting the renounceOwnership(..) 2-step process.


Errors​

LSP14CallerNotPendingOwner​

References
error LSP14CallerNotPendingOwner(address caller);

Reverts when the caller that is trying to accept ownership of the contract is not the pending owner.

Parameters​

NameTypeDescription
calleraddressThe address that tried to accept ownership.

LSP14CannotTransferOwnershipToSelf​

References
error LSP14CannotTransferOwnershipToSelf();

Cannot transfer ownership to the address of the contract itself.

Reverts when trying to transfer ownership to the address(this).


LSP14MustAcceptOwnershipInSeparateTransaction​

References
error LSP14MustAcceptOwnershipInSeparateTransaction();

Cannot accept ownership in the same transaction with transferOwnership(...).

Reverts when pending owner accept ownership in the same transaction of transferring ownership.


LSP14NotInRenounceOwnershipInterval​

References
error LSP14NotInRenounceOwnershipInterval(
uint256 renounceOwnershipStart,
uint256 renounceOwnershipEnd
);

Cannot confirm ownership renouncement yet. The ownership renouncement is allowed from: renounceOwnershipStart until: renounceOwnershipEnd.

Reverts when trying to renounce ownership before the initial confirmation delay.

Parameters​

NameTypeDescription
renounceOwnershipStartuint256The start timestamp when one can confirm the renouncement of ownership.
renounceOwnershipEnduint256The end timestamp when one can confirm the renouncement of ownership.

OwnableCallerNotTheOwner​

References
error OwnableCallerNotTheOwner(address callerAddress);

Reverts when only the owner is allowed to call the function.

Parameters​

NameTypeDescription
callerAddressaddressThe address that tried to make the call.