Skip to main content

Access Control Renounce Facet

Renounces roles for accounts within a diamond.

Key Features
  • Exposes an external renounceRole function for role management.
  • Emits RoleRevoked event upon successful role renouncement.
  • Reverts with AccessControlUnauthorizedSender if the caller is not the target account.
  • Compatible with ERC-2535 diamond standard.

Overview

This facet provides functionality to renounce roles for accounts in a diamond. It exposes the renounceRole function, allowing authorized accounts to relinquish their assigned roles. Calls are routed through the diamond proxy, ensuring consistent access control and upgradeability.

Storage

AccessControlStorage

Definition
struct AccessControlStorage {
mapping(address account => mapping(bytes32 role => bool hasRole)) hasRole;
mapping(bytes32 role => bytes32 adminRole) adminRole;
}

State Variables

PropertyTypeDescription
STORAGE_POSITIONbytes32Diamond storage slot position for this module (Value: keccak256("compose.accesscontrol"))

Functions

renounceRole

Renounces a role from the caller. Emits a RoleRevoked event. Reverts with AccessControlUnauthorizedSender If the caller is not the account to renounce the role from.

function renounceRole(bytes32 _role, address _account) external;

Parameters:

PropertyTypeDescription
_rolebytes32The role to renounce.
_accountaddressThe account to renounce the role from.

exportSelectors

Exports the selectors that are exposed by the facet.

function exportSelectors() external pure returns (bytes memory);

Returns:

PropertyTypeDescription
-bytesSelectors that are exported by the facet.

Events

Errors

Best Practices

Best Practice
  • Call renounceRole through the diamond proxy to ensure proper access control checks.
  • Ensure the caller is the account from which the role is being renounced to prevent unauthorized revocations.
  • Verify the RoleRevoked event is emitted and correctly interpreted by off-chain services.

Security Considerations

Security

The renounceRole function is protected by access control, ensuring only the account itself can renounce its role. The facet does not perform external calls, mitigating reentrancy risks. Input validation is handled by the underlying access control logic within the diamond.

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.