Skip to main content

Owner Transfer Module

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

Helper functions for ownership transfer and storage access.

Key Features
  • transferOwnership guards by requiring msg.sender is the current owner.
  • Emits OwnershipTransferred on successful transfers.
Module Usage

Use helper functions from Compose using your own custom facets. See Facets & Modules for more information.

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

getStorage

Returns a pointer to the OwnerStorage struct.

function getStorage() pure returns (OwnerStorage storage s);

Returns:

PropertyTypeDescription
sOwnerStorage storageThe struct in storage.

transferOwnership

Transfer the diamond ownership from the current owner to the next one. Caller must be the current owner.

_newOwner may be address(0) to clear ownership (same storage effect as renounceOwnership() in OwnerRenounceMod).

function transferOwnership(address _newOwner);

Parameters:

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

Events

Errors

Best Practices

  • Call transferOwnership only from trusted external wrappers; confirm _newOwner before sending a transaction.
  • Keep the same STORAGE_POSITION and OwnerStorage layout as other owner modules; do not introduce a second owner slot.
  • If you want a dedicated renounce entrypoint in Solidity, prefer OwnerRenounceMod or pass address(0) here. Both target the same storage field.

Integration Notes

OwnerStorage lives at keccak256("erc173.owner") inside the diamond. The same slot as OwnerDataMod, OwnerTransferFacet, and related owner code. Transferring here updates what owner() reads on OwnerDataFacet.

Last updated:

Newsletter

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

No spam. Unsubscribe anytime.