Owner Transfer Facet
Manages diamond ownership and transfers
- Manages diamond ownership via external functions.
- Leverages diamond storage for owner state.
- Provides
exportSelectorsfor facet discovery. - Compatible with ERC-2535 diamond standard.
Overview
This facet provides external functions for managing the ownership of a Compose diamond. It enables transferring ownership and renouncing it, interacting with diamond storage for owner information. Developers integrate this facet to establish clear ownership and control within their diamond architecture.
Storage
OwnerStorage
State Variables
| Property | Type | Description |
|---|---|---|
STORAGE_POSITION | bytes32 | Diamond storage slot position for this module (Value: keccak256("erc173.owner")) |
Functions
transferOwnership
Set the address of the new owner of the contract. Set _newOwner to address(0) to renounce any ownership.
Parameters:
| Property | Type | Description |
|---|---|---|
_newOwner | address | The address of the new owner of the contract. |
exportSelectors
Exports the function selectors of the OwnerTransferFacet This function is use as a selector discovery mechanism for diamonds
Returns:
| Property | Type | Description |
|---|---|---|
- | bytes | selectors The exported function selectors of the OwnerTransferFacet |
Events
Errors
Best Practices
- Initialize the owner address during diamond deployment.
- Enforce access control for state-changing functions like
transferOwnership. - Verify compatibility with
OwnerDataFacetandOwnerRenounceFacetwhen composing access control functionalities.
Security Considerations
State-changing functions, particularly transferOwnership, must be protected by appropriate access control mechanisms (e.g., Ownable or role-based access control) to prevent unauthorized ownership changes. Ensure the caller has the necessary permissions before executing transferOwnership. Renouncing ownership by setting the new owner to address(0) is irreversible. Follow standard Solidity security practices for input validation and reentrancy.