Owner Transfer Module
Manages ERC-173 ownership transfer and renouncement
- Manages ERC-173 ownership transfers and renouncements.
- Operates on shared diamond storage, ensuring cross-facet visibility.
- Provides
internalfunctions for integration within custom facets. - Reverts with
OwnerUnauthorizedAccountif ownership rules are violated.
This module provides internal functions for use in your custom facets. Import it to access shared logic and storage.
Overview
This module provides core ERC-173 ownership transfer logic, enabling diamonds to manage ownership securely. Facets can use its internal functions to transfer ownership or renounce it, ensuring clear accountability within the diamond. Changes to ownership are immediately reflected across all facets sharing the same diamond storage.
Storage
OwnerStorage
storage-location: erc8042:erc173.owner
State Variables
| Property | Type | Description |
|---|---|---|
STORAGE_POSITION | bytes32 | Diamond storage slot position for this module (Value: keccak256("erc173.owner")) |
Functions
getStorage
Returns a pointer to the ERC-173 storage struct. Uses inline assembly to access the storage slot defined by STORAGE_POSITION.
Returns:
| Property | Type | Description |
|---|---|---|
s | OwnerStorage | The OwnerStorage struct in storage. |
transferOwnership
Set the address of the new owner of the contract. Set _newOwner to address(0) to renounce any ownership.
Parameters:
| Property | Type | Description |
|---|---|---|
_newOwner | address | The address of the new owner of the contract. |
Events
Errors
Best Practices
- Ensure ownership is transferred or renounced only by the current owner.
- Call
transferOwnershipwithaddress(0)to safely renounce ownership. - Use
getStorageto inspect ownership state, ensuring consistency across facets.
Integration Notes
This module utilizes diamond storage at the STORAGE_POSITION slot, identified by keccak256("erc173.owner"), to manage the OwnerStorage struct. The owner field within this struct represents the diamond's owner. All functions operate internally and directly on this shared storage, making ownership changes immediately visible to any facet that reads from the same storage slot.