Owner Data Module
@perfect-abstractions/compose/access/Owner/Data/OwnerDataMod.solHelper functions for owner storage, reads, and owner check based on ERC-173
requireOwner()guards by requiringmsg.senderis the stored owner.setContractOwnerhas no access control validation (Trusted initialization only).- Emits
OwnershipTransferredfromsetContractOwnerwithpreviousOwner == address(0).
You can use modules to wrap around you own project logic while using the default Compose building blocks. Modules provides all the necessary internal helpers for maximum integration.
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 OwnerStorage struct.
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
Verify if the message sender is the current diamond owner. Useful for gating specify logic inside your own facets.
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.