Owner Two Step Transfer Module
Two-step ERC-173 ownership transfer logic
- Two-step handoff: current owner calls
transferOwnership; the nominated address callsacceptOwnershipto finalize (unlike single-stepOwnerTransferMod). - Uses
erc8042:erc173.owneranderc8042:erc173.owner.pending; same layout as Owner Two Step Transfer Facet. - File-level
getOwnerStorage,getPendingOwnerStorage,transferOwnership, andacceptOwnership; emitsOwnershipTransferStartedthenOwnershipTransferredwhen acceptance completes.
Import this module into facets or shared setup code. Its helpers are file-level (effectively internal to your compilation unit). Call them from your facet’s external entrypoints.
Storage follows the diamond slot layout in this file; any code using the same OWNER_STORAGE_POSITION or PENDING_OWNER_STORAGE_POSITION shares state.
See Facets & Modules for more information.
Storage
State Variables
| Property | Type | Description |
|---|---|---|
OWNER_STORAGE_POSITION | bytes32 | Owner storage position within the diamond (Value: keccak256("erc173.owner")) |
PENDING_OWNER_STORAGE_POSITION | bytes32 | Pending owner storage position within the diamond (Value: keccak256("erc173.owner.pending")) |
OwnerStorage
PendingOwnerStorage
Functions
getOwnerStorage
Returns a storage pointer to OwnerStorage at OWNER_STORAGE_POSITION using inline assembly.
Returns:
| Property | Type | Description |
|---|---|---|
s | OwnerStorage storage | The owner struct in diamond storage. |
getPendingOwnerStorage
Returns a storage pointer to PendingOwnerStorage at PENDING_OWNER_STORAGE_POSITION using inline assembly.
Returns:
| Property | Type | Description |
|---|---|---|
s | PendingOwnerStorage storage | The pending-owner struct in diamond storage. |
transferOwnership
Requires msg.sender == owner; otherwise reverts OwnerUnauthorizedAccount. Sets pendingOwner to _newOwner and emits OwnershipTransferStarted(owner, _newOwner). Does not change owner until acceptOwnership.
Parameters:
| Property | Type | Description |
|---|---|---|
_newOwner | address | Address that must call acceptOwnership to become owner. |
acceptOwnership
Requires msg.sender == pendingOwner; otherwise reverts OwnerUnauthorizedAccount. Assigns owner to the pending address, clears pendingOwner, and emits OwnershipTransferred(previousOwner, newOwner).
Events
Errors
Best Practices
- Expose
transferOwnershipandacceptOwnershiponly through vettedexternalfacet entrypoints; confirm_newOwnerbefore initiating. - Keep the same
OwnerStorage/PendingOwnerStoragelayout as Owner Two Step Transfer Facet and Owner Two Step Data Module owneris shared withOwnerDataModand single-step owner code atkeccak256("erc173.owner").