Skip to main content

Owner Two Step Transfer Facet

Manages ownership transfer via a two-step process

Key Features
  • Exposes external functions for diamond routing.
  • Manages ownership transfer through a two-step verification process.
  • Operates on shared diamond storage using inline assembly.
  • Provides a mechanism to export facet selectors.

Overview

This facet implements a two-step ownership transfer mechanism for a diamond. It exposes external functions for initiating and accepting ownership changes, operating on shared diamond storage. Developers integrate this facet to manage diamond ownership securely and upgradeably.

Storage

OwnerStorage

Definition
struct OwnerStorage {
address owner;
}

PendingOwnerStorage

Definition
struct PendingOwnerStorage {
address pendingOwner;
}

State Variables

PropertyTypeDescription
OWNER_STORAGE_POSITIONbytes32Diamond storage slot position for this module (Value: keccak256("erc173.owner"))
PENDING_OWNER_STORAGE_POSITIONbytes32Diamond storage slot position for this module (Value: keccak256("erc173.owner.pending"))

Functions

transferOwnership

Set the address of the new owner of the contract

function transferOwnership(address _newOwner) external;

Parameters:

PropertyTypeDescription
_newOwneraddressThe address of the new owner of the contract

acceptOwnership

function acceptOwnership() external;

exportSelectors

Exports the function selectors of the OwnerTwoStepTransferFacet This function is use as a selector discovery mechanism for diamonds

function exportSelectors() external pure returns (bytes memory);

Returns:

PropertyTypeDescription
-bytesselectors The exported function selectors of the OwnerTwoStepTransferFacet

Events

Errors

Best Practices

Best Practice
  • Initialize the owner address during diamond deployment.
  • Ensure the transferOwnership function is called by the current owner.
  • Verify that the acceptOwnership function is called by the pending owner address.

Security Considerations

Security

The transferOwnership function is restricted to the current owner via internal access control checks within the facet. The acceptOwnership function requires the caller to be the pending owner. No reentrancy guards are explicitly present; follow standard Solidity reentrancy best practices for external calls within the diamond.

Was this helpful?
Last updated:

Newsletter

Get notified about releases, feature announcements, and technical deep-dives on building smart contracts with Compose.

No spam. Unsubscribe anytime.