Skip to main content

Owner Transfer Facet

@perfect-abstractions/compose/access/Owner/Transfer/OwnerTransferFacet.sol

Transfer your diamonds ownership

Key Features
  • transferOwnership writes into the OwnerStorage at erc8042:erc173.owner.
  • _newOwner may be address(0) to clear ownership. (Similar to renounceOwnership)
  • Transfers require the caller to be the curent owner

Storage

State Variables

PropertyTypeDescription
STORAGE_POSITIONbytes32Owner storage position within the diamond (Value: keccak256("erc173.owner"))

OwnerStorage

Definition
/** @custom:storage-location erc8042:erc173.owner */
struct OwnerStorage {
address owner;
}

Functions

transferOwnership

Change the contract ownership to the _newOwner address.

You can replicate the renouncement by setting the new owner to address(0). This action is irreversible.

function transferOwnership(address _newOwner) external;

Parameters:

PropertyTypeDescription
_newOwneraddressThe next owner, or address(0) to clear ownership.

Events

Errors

Best Practices

  • Initialize OwnerStorage.owner during deployment (or via a one-time setup) before relying on owner-only features elsewhere.
  • Confirm _newOwner is the intended address; transfers are immediate and cannot be reverse.
  • Keep owner state in a single slot: do not add another facet that writes a second “owner” elsewhere. Except id dual ownership is intend.
  • If you need two-step acceptance or pending-owner flows, consider the Two Steps ownership utilities in addition to this facet.

Security Considerations

transferOwnership is restricted to the address currently stored as owner (msg.sender == s.owner). The facet does not implement any additional role system.

The main risks are social and operational: transferring to the wrong address, or setting _newOwner to address(0) when you did not intend to remove all owner control.

Last updated:

Newsletter

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

No spam. Unsubscribe anytime.