Skip to main content

Owner Data Facet

Read-only ERC-173 owner data access for diamonds

Key Features
  • Exposes the contract owner via external owner() (ERC-173).
  • Shares OwnerStorage at erc8042:erc173.owner with OwnerDataMod and other owner facets.
  • No state-changing functions; initialization and ownership changes use other facets or the module.

Storage

State Variables

PropertyTypeDescription
STORAGE_POSITIONbytes32Owner storage position within the diamond (Value: keccak256("erc173.owner"))

OwnerStorage

Definition
/** storage-location: erc8042:erc173.owner */
struct OwnerStorage {
address owner;
}

Functions

owner

Returns the address stored in OwnerStorage.owner.

function owner() external view returns (address);

Returns:

PropertyTypeDescription
-addressThe current owner, or address(0) if unset or renounced.

Best Practices

  • Initialize or transfer ownership with a facet that uses OwnerDataMod (for example OwnerTransferFacet) so owner() reflects the real owner before relying on this facet in production.
  • Register this facet with the diamond using exportSelectors() so owner() is routed correctly after cuts or upgrades.
  • Avoid defining a second facet that writes to a different owner slot; keep all owner state at erc173.owner.
Was this helpful?
Last updated:

Newsletter

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

No spam. Unsubscribe anytime.