Owner Data Module
Manages ERC-173 contract ownership using diamond storage
- Provides internal functions for ERC-173 ownership management.
- Utilizes diamond storage pattern for shared state.
- No external dependencies, promoting composability.
- Functions are
internaland designed for use within custom facets.
This module provides internal functions for use in your custom facets. Import it to access shared logic and storage.
Overview
This module provides internal functions for managing ERC-173 contract ownership. Facets can import this module to check and set the contract owner using shared diamond storage. Changes to ownership are immediately visible to all facets accessing the same storage slot.
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. |
owner
Get the address of the owner
Returns:
| Property | Type | Description |
|---|---|---|
- | address | The address of the owner. |
requireOwner
Reverts if the caller is not the owner.
setContractOwner
Parameters:
| Property | Type | Description |
|---|---|---|
_initialOwner | address | - |
Events
Errors
Best Practices
- Ensure access control is enforced by the calling facet before invoking
setContractOwner. - Verify that the
OwnerStoragestruct and its storage position are correctly configured within the diamond's storage layout. - Handle
OwnerUnauthorizedAccountandOwnerAlreadyRenouncederrors if applicable to your facet's logic.
Integration Notes
This module manages ownership state within the diamond's shared storage. It uses the OwnerStorage struct, located at the STORAGE_POSITION slot, identified by keccak256("erc173.owner"). The owner address is stored here. Any facet that accesses this storage position will see the current owner address. Functions like owner() and requireOwner() directly read from this slot, ensuring consistent ownership information across the diamond.