---
eip: 7820
label: ERC-7820
title: Access Control Registry
status: Final
type: Standards Track
category: ERC
created: 2024-11-19
official: https://eips.ethereum.org/EIPS/eip-7820
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7820.md
canonical: https://eips.huatuo.xyz/eip-7820/
lang: en
tldr: "A shared registry contract that manages role-based access control for many contracts at once: contracts register with an admin, roles are granted or revoked in batches, and anyone can check them."
tags: [access-control, roles, registry, security, solidity]
---

# ERC-7820: Access Control Registry

> Registration, unregistration, role assignment, and role revocation for contracts, ensuring secure and transparent role management.

**TL;DR:** A shared registry contract that manages role-based access control for many contracts at once: contracts register with an admin, roles are granted or revoked in batches, and anyone can check them.

## What problem does it solve?

Almost every protocol needs "who may call what": minters, pausers, upgraders, operators. Usually each contract embeds its own access control (for example OpenZeppelin `AccessControl` or `Ownable`, [ERC-173](/eip-173/)). In a system with many contracts, that means roles are scattered, duplicated and hard to audit, and granting one operator rights everywhere takes many transactions.

ERC-7820 defines an **Access Control Registry (ACR)**: one contract that holds the role tables for many other contracts, with a common interface and events.

## How it works

- **Registration.** A contract calls `registerContract(admin)` on the registry itself, so `msg.sender` is the contract being registered. It names an admin, which cannot be the zero address. There is no central owner of the registry.
- **Role management.** `grantRole(targets[], roles[], accounts[])` and `revokeRole(...)` take parallel arrays, so many grants across many contracts happen in one call. In the reference implementation, each entry must be authorized by that target's admin or the target contract itself, and the target must be active.
- **Checks.** Contracts (or anyone) ask the registry whether an account holds a role for a given target. Roles are `bytes32` values, like `keccak256("MINTER_ROLE")`.
- **Unregistration.** The admin can call `unRegisterContract(target)`, marking it inactive so further grants and revokes fail.
- **Events.** `ContractRegistered`, `ContractUnregistered`, `RoleGranted` and `RoleRevoked` give a full audit trail.

## Sample code

A token that delegates its access checks to a registry. It uses the reference implementation's three-argument `getRoleInfo`:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

interface IACR {
    function registerContract(address admin) external;
    function getRoleInfo(address target, address account, bytes32 role) external view returns (bool);
}

contract RegistryControlledToken {
    bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
    IACR public immutable acr;
    mapping(address => uint256) public balanceOf;

    constructor(IACR _acr, address admin) {
        acr = _acr;
        _acr.registerContract(admin); // msg.sender seen by the registry = this contract
    }

    modifier onlyRole(bytes32 role) {
        require(acr.getRoleInfo(address(this), msg.sender, role), "missing role");
        _;
    }

    function mint(address to, uint256 amount) external onlyRole(MINTER_ROLE) {
        balanceOf[to] += amount;
    }
}
```

The admin then grants roles for several contracts in one transaction (ethers v6):

```ts
import { Contract, id } from "ethers";

const acr = new Contract(ACR_ADDRESS, [
  "function grantRole(address[] targets, bytes32[] roles, address[] accounts)",
], adminSigner);

await acr.grantRole(
  [tokenAddress, vaultAddress],          // targets
  [id("MINTER_ROLE"), id("PAUSER_ROLE")], // roles (keccak256 of the name)
  [operator, operator],                   // accounts
);
```

## Things to know

- Status is **Final**.
- The interface in the spec has an inconsistency: `IAccessControlRegistry.getRoleInfo(address)` is declared with the same signature and comment as `getContractInfo`, while the rationale and reference implementation use `getRoleInfo(target, account, role) returns (bool)`. Check which one a deployed registry actually exposes.
- A shared registry is a single point of failure. A bug, or a compromised admin key, affects every contract registered under that admin, so audit it carefully and use a multisig admin.
- Every role check is an external call, which costs more gas than reading local storage.
- In the reference implementation, revoking a role that is not held reverts, so one bad entry makes a whole batched `revokeRole` fail.


---

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