Owner Data Module
ERC-173 ownership storage and helpers for diamond facets
- Helper functions for owner storage, reads, and owner checks.
requireOwner()guards by requiringmsg.senderis the stored owner;setContractOwnerhas no access checks (trusted initialization only).- Emits
OwnershipTransferredfromsetContractOwnerwithpreviousOwner == address(0).
Import this module into facets or shared setup code. Its functions are internal (including Solidity file-level helpers). Use them through your facet’s external entrypoints.
Storage follows the diamond slot layout in this file; any code using the same STORAGE_POSITION or related positions reads and writes shared state.
See Facets & Modules for more information.
Storage
State Variables
| Property | Type | Description |
|---|---|---|
STORAGE_POSITION | bytes32 | Owner storage position within the diamond (Value: keccak256("erc173.owner")) |
OwnerStorage
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 storage | The struct in storage. |
owner
Get the address of the owner
Returns:
| Property | Type | Description |
|---|---|---|
- | address | The stored owner, or address(0) if never set or cleared. |
requireOwner
Reverts with OwnerUnauthorizedAccount unless msg.sender equals the current owner.
Reverts:
| Property | Type | Description |
|---|---|---|
OwnerUnauthorizedAccount | error | Caller is not the current owner. |
setContractOwner
Writes the inital owner address to storage and emits OwnershipTransferred(address(0), _initialOwner).
There is no msg.sender or role check performed. Use only from trusted initialization code, or wrap with your own checks in a facet.
Parameters:
| Property | Type | Description |
|---|---|---|
_initialOwner | address | The address of the initial owner. |
Events
Errors
Best Practices
- Call
setContractOwneronly from trusted init paths (constructor, one-off setup). For transfers, useOwnerTransferMod.transferOwnershipor an equivalent facet so events record the real previous owner. - Guard external entrypoints with
requireOwner()or equivalent before state changes restricted to the owner.
Integration Notes
OwnerStorage is located at keccak256("erc173.owner") inside the diamond.
All Compose Owner contracts use that slot, so owner() and transfer logic observe the same address.