Skip to main content

Owner Two Step Transfer Facet

Two-step ERC-173 ownership transfer for Compose diamonds

Key Features
  • Two-step handoff: the owner calls transferOwnership; the nominated address calls acceptOwnership to become owner.
  • Storage uses erc8042:erc173.owner and erc8042:erc173.owner.pending, shared with the two-step transfer module.

Storage

State Variables

PropertyTypeDescription
OWNER_STORAGE_POSITIONbytes32Owner storage position within the diamond (Value: keccak256("erc173.owner"))
PENDING_OWNER_STORAGE_POSITIONbytes32Pending owner storage position within the diamond (Value: keccak256("erc173.owner.pending"))

OwnerStorage

Definition
/** storage-location: erc8042:erc173.owner */
struct OwnerStorage {
address owner;
}

PendingOwnerStorage

Definition
/** storage-location: erc8042:erc173.owner.pending */
struct PendingOwnerStorage {
address pendingOwner;
}

Functions

transferOwnership

Callable only when msg.sender is the current owner; otherwise reverts OwnerUnauthorizedAccount. Sets pendingOwner to _newOwner and emits OwnershipTransferStarted(owner, _newOwner). The on-chain owner does not change until acceptOwnership.

function transferOwnership(address _newOwner) external;

Parameters:

PropertyTypeDescription
_newOwneraddressAddress that will become owner after a successful acceptOwnership from that address.

acceptOwnership

Callable only when msg.sender is the pending owner; otherwise reverts OwnerUnauthorizedAccount. Assigns owner to the pending address, sets pendingOwner to address(0), and emits OwnershipTransferred(previousOwner, newOwner).

function acceptOwnership() external;

Events

Errors

Best Practices

  • Initialize OwnerStorage.owner during deployment before relying on owner-only behavior elsewhere.
  • After transferOwnership, ensure the nominated _newOwner can and will call acceptOwnership; until then, the previous owner remains owner.
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.