OwnerTwoStepsFacet
Manage diamond ownership and transfers
- Manages diamond ownership via a two-step transfer process.
- Exposes
owner()andpendingOwner()view functions. - Provides
transferOwnership(),acceptOwnership(), andrenounceOwnership()external functions. - Utilizes dedicated storage slots for owner and pending owner state.
Overview
This facet provides ownership management for a diamond, enabling secure transfers and renouncements. It exposes external functions to view current and pending owners, initiate ownership transfers, and accept or renounce ownership, all integrated within the diamond proxy pattern.
Storage
OwnerStorage
PendingOwnerStorage
State Variables
| Property | Type | Description |
|---|---|---|
OWNER_STORAGE_POSITION | bytes32 | Diamond storage slot position for this module (Value: keccak256("compose.owner")) |
PENDING_OWNER_STORAGE_POSITION | bytes32 | Diamond storage slot position for this module (Value: keccak256("compose.owner.pending")) |
Functions
owner
Get the address of the owner
Returns:
| Property | Type | Description |
|---|---|---|
- | address | The address of the owner. |
pendingOwner
Get the address of the pending owner
Returns:
| Property | Type | Description |
|---|---|---|
- | address | The address of the pending owner. |
transferOwnership
Set the address of the new owner of the contract
Parameters:
| Property | Type | Description |
|---|---|---|
_newOwner | address | The address of the new owner of the contract |
acceptOwnership
renounceOwnership
Events
Errors
Best Practices
- Initialize ownership during diamond deployment using
transferOwnership. - Ensure the current owner calls
transferOwnershipto initiate a transfer. - The new owner must call
acceptOwnershipto finalize the transfer. - Use
renounceOwnershipwith caution to remove ownership permanently.
Security Considerations
The transferOwnership function can only be called by the current owner. The acceptOwnership function can only be called by the pending owner. The renounceOwnership function can only be called by the current owner. All state-changing functions enforce these access controls to prevent unauthorized actions. Follow standard Solidity security practices for input validation.