---
eip: 5982
label: ERC-5982
title: Role-based Access Control
status: Review
type: Standards Track
category: ERC
created: 2022-11-15
requires: 165, 5750
official: https://eips.ethereum.org/EIPS/eip-5982
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-5982.md
canonical: https://eips.huatuo.xyz/eip-5982/
lang: en
tldr: A standard interface for role-based access control, where bytes32 roles are granted to addresses and checked before privileged functions run.
tags: [access-control, roles, security, interface]
---

# ERC-5982: Role-based Access Control

> An interface for role-based access control for smart contracts.

**TL;DR:** A standard interface for role-based access control, where bytes32 roles are granted to addresses and checked before privileged functions run.

## What problem does it solve?

Many contracts gate sensitive functions (mint, pause, upgrade) behind a single `owner`. That is simple but fragile: one key does everything, and you cannot give a bot permission to mint without also giving it permission to upgrade.

Role-based access control (RBAC) assigns addresses to named roles, each allowed to do only certain things, following the principle of least privilege. The pattern is already common (OpenZeppelin's `AccessControl`), but there was no ERC describing it so tools could detect and manage roles across contracts. ERC-5982 proposes that interface, deliberately compatible with OpenZeppelin's method names.

## How it works

A role is a `bytes32`, recommended to be `keccak256("<ROLE_NAME>")`, for example `keccak256("MINTER")`.

The spec has three layers:

- **`IERC_ACL_CORE` (required):** `hasRole(role, account)`, `grantRole(role, account)`, `revokeRole(role, account)`.
- **`IERC_ACL_GENERAL` (recommended):** versions of those calls with an extra `bytes _data` argument (following [ERC-5750](/eip-5750/)), plus `createRole`, `destroyRole`, `setRolePower` to bind a role to function selectors (`bytes4`), and `canGrantRole` / `canRevokeRole` / `canExecute` checks. Matching events (`RoleGranted`, `RoleRevoked`, `RoleCreated`, …) record changes.
- **`IERC_ACL_METADATA` (optional):** `roleName`, `roleDescription`, `roleURI` for human-readable role information.

Contracts should advertise support through [ERC-165](/eip-165/). Unlike OpenZeppelin, there is no separate `renounceRole`; that case is folded into `revokeRole`.

## Sample code

A minimal contract implementing the core interface:

```solidity
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;

interface IERC_ACL_CORE {
    function hasRole(bytes32 role, address account) external view returns (bool);
    function grantRole(bytes32 role, address account) external;
    function revokeRole(bytes32 role, address account) external;
}

contract RoleGated is IERC_ACL_CORE {
    bytes32 public constant ADMIN  = keccak256("ADMIN");
    bytes32 public constant MINTER = keccak256("MINTER");
    mapping(bytes32 => mapping(address => bool)) private _roles;

    constructor() { _roles[ADMIN][msg.sender] = true; }

    modifier only(bytes32 role) {
        require(_roles[role][msg.sender], "missing role");
        _;
    }

    function hasRole(bytes32 role, address a) external view returns (bool) { return _roles[role][a]; }
    function grantRole(bytes32 role, address a) external only(ADMIN) { _roles[role][a] = true; }
    function revokeRole(bytes32 role, address a) external {
        require(_roles[ADMIN][msg.sender] || a == msg.sender, "not allowed"); // self-revoke allowed
        _roles[role][a] = false;
    }

    function mint(address to, uint256 amount) external only(MINTER) { /* ... */ }
}
```

## Things to know

- **Status: Review.** The interface may still change. Its Backwards Compatibility and Security Considerations sections still read "Needs discussion".
- The core interface matches OpenZeppelin's `AccessControl` function signatures, so existing OZ-based contracts already expose the required methods.
- The general extension's code in the spec has some rough edges (e.g. `bytes32 calldata` parameters and a `view` setter), so treat it as a sketch rather than copy-paste Solidity.
- Whoever administers roles is now your critical key. Protect admin roles with a multisig or timelock.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-5982
