Owner Transfer Facet
@perfect-abstractions/compose/access/Owner/Transfer/OwnerTransferFacet.solTransfer your diamonds ownership
Key Features
transferOwnershipwrites into theOwnerStorageaterc8042:erc173.owner._newOwnermay beaddress(0)to clear ownership. (Similar torenounceOwnership)- Transfers require the caller to be the curent owner
Storage
State Variables
| Property | Type | Description |
|---|---|---|
STORAGE_POSITION | bytes32 | Owner storage position within the diamond (Value: keccak256("erc173.owner")) |
OwnerStorage
Functions
transferOwnership
Change the contract ownership to the _newOwner address.
You can replicate the renouncement by setting the new owner to address(0). This action is irreversible.
Parameters:
| Property | Type | Description |
|---|---|---|
_newOwner | address | The next owner, or address(0) to clear ownership. |
Events
Errors
Best Practices
- Initialize
OwnerStorage.ownerduring deployment (or via a one-time setup) before relying on owner-only features elsewhere. - Confirm
_newOwneris the intended address; transfers are immediate and cannot be reverse. - Keep owner state in a single slot: do not add another facet that writes a second “owner” elsewhere. Except id dual ownership is intend.
- If you need two-step acceptance or pending-owner flows, consider the Two Steps ownership utilities in addition to this facet.
Security Considerations
transferOwnership is restricted to the address currently stored as owner (msg.sender == s.owner). The facet does not implement any additional role system.
The main risks are social and operational: transferring to the wrong address, or setting _newOwner to address(0) when you did not intend to remove all owner control.
Last updated: