Skip to main content

Owner Two Step Renounce Module

Two-step ownership renouncement with ERC-173 logic

Key Features
  • Implements a two-step ownership renouncement pattern.
  • Uses internal functions for direct interaction with diamond storage.
  • Emits an OwnershipTransferred event upon successful renouncement.
  • Compatible with ERC-2535 diamonds and the shared storage pattern.
Module Usage

This module provides internal functions for use in your custom facets. Import it to access shared logic and storage.

Overview

This module implements a two-step ownership renouncement process, adhering to ERC-173 semantics. It provides internal functions to manage ownership transitions, ensuring that functions restricted to the owner are disabled only after a confirmed two-step process. This approach enhances security by preventing accidental or malicious immediate ownership loss.

Storage

OwnerStorage

storage-location: erc8042:erc173.owner

Definition
struct OwnerStorage {
address owner;
}

PendingOwnerStorage

storage-location: erc8042:erc173.owner.pending

Definition
struct PendingOwnerStorage {
address pendingOwner;
}

State Variables

PropertyTypeDescription
OWNER_STORAGE_POSITIONbytes32Diamond storage slot position for this module (Value: keccak256("erc173.owner"))
PENDING_OWNER_STORAGE_POSITIONbytes32Diamond storage slot position for this module (Value: keccak256("erc173.owner.pending"))

Functions

getOwnerStorage

Returns a pointer to the ERC-173 storage struct. Uses inline assembly to access the storage slot defined by OWNER_STORAGE_POSITION.

function getOwnerStorage() pure returns (OwnerStorage storage s);

Returns:

PropertyTypeDescription
sOwnerStorageThe OwnerStorage struct in storage.

getPendingOwnerStorage

Returns a pointer to the PendingOwner storage struct. Uses inline assembly to access the storage slot defined by PENDING_OWNER_STORAGE_POSITION.

function getPendingOwnerStorage() pure returns (PendingOwnerStorage storage s);

Returns:

PropertyTypeDescription
sPendingOwnerStorageThe PendingOwnerStorage struct in storage.

renounceOwnership

Renounce ownership of the contract. Sets the owner to address(0) and clears any pending owner, disabling all functions restricted to the owner.

function renounceOwnership() ;

Events

Errors

Best Practices

Best Practice
  • Ensure the caller has the appropriate permissions before invoking state-changing functions.
  • Verify that the OWNER_STORAGE_POSITION and PENDING_OWNER_STORAGE_POSITION are correctly configured in the diamond's storage layout.
  • Handle the OwnerUnauthorizedAccount error if the caller is not the authorized account for ownership operations.

Integration Notes

Shared Storage

This module interacts with diamond storage at the slots defined by OWNER_STORAGE_POSITION and PENDING_OWNER_STORAGE_POSITION. The renounceOwnership function directly modifies the owner field within the OwnerStorage struct located at OWNER_STORAGE_POSITION, setting it to address(0) and clearing any pending owner. These changes are immediately visible to all facets that access the same storage slots.

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.