Skip to content
Lattice

AccessControl

Git Source

Title: AccessControl

Author: Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/AccessControl.sol)

AccessControl is a contract module that allows children to implement role-based access control mechanisms. This is a lightweight version that doesn't include enumeration of role members.

See AccessControlEnumerable if you need to enumerate role members.

Notes:

  • lattice-version: 0.1.0
  • lattice-source: OpenZeppelin v5.1.0

Functions

hasRole

Checks whether an account has a specific role.

function hasRole(bytes32 _role, address _account) public view virtual returns (bool);

Parameters

NameTypeDescription
_rolebytes32The role identifier to check.
_accountaddressThe account address to verify.

Returns

NameTypeDescription
<none>boolbool True if the account has the role, false otherwise.

getRoleAdmin

Gets the admin role that controls a specific role.

function getRoleAdmin(bytes32 _role) public view virtual returns (bytes32);

Parameters

NameTypeDescription
_rolebytes32The role identifier to query.

Returns

NameTypeDescription
<none>bytes32bytes32 The admin role that can grant or revoke the specified role.

grantRole

Grants a role to an account.

Only callable by accounts holding the admin role for the target role. Emits a RoleGranted event if the role was not already held by the account.

function grantRole(bytes32 _role, address _account) public virtual;

Parameters

NameTypeDescription
_rolebytes32The role identifier to grant.
_accountaddressThe account address to grant the role to.

revokeRole

Revokes a role from an account.

Only callable by accounts holding the admin role for the target role. Emits a RoleRevoked event if the account currently holds the role.

function revokeRole(bytes32 _role, address _account) public virtual;

Parameters

NameTypeDescription
_rolebytes32The role identifier to revoke.
_accountaddressThe account address to revoke the role from.

renounceRole

Renounces a role from the caller's account.

This allows accounts to lose privileges if compromised (e.g., misplaced keys). Emits a RoleRevoked event if the caller currently holds the role. The _callerConfirmation parameter must match msg.sender for security.

function renounceRole(bytes32 _role, address _callerConfirmation) public virtual;

Parameters

NameTypeDescription
_rolebytes32The role identifier to renounce.
_callerConfirmationaddressThe caller's address as a confirmation parameter.

exportSelectors

ERC-8153 selector export: this facet's cuttable selectors, tightly packed (4 bytes each).

Excludes exportSelectors() itself (0x0ef22643) - it is never cut into a diamond. Order matches forge inspect AccessControl methodIdentifiers (alphabetical by signature); kept in exact parity by ExportSelectorsParityTest. Chunks: getRoleAdmin(bytes32) 0x248a9ca3 grantRole(bytes32,address) 0x2f2ff15d hasRole(bytes32,address) 0x91d14854 renounceRole(bytes32,address) 0x36568abe revokeRole(bytes32,address) 0xd547741f

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

Returns

NameTypeDescription
selectorsbytes