Introduction
Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.
I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.
I also build and publish a variety of tools, libraries, and open-source projects.
This article examines ERC-6617, a standard proposing a bit-based permission management system.
This article translates, summarizes, and supplements the material linked below.
The original article recorded ERC-6617 as being in the Review stage on January 10, 2024.
I have also covered other EIPs.
Overview
This EIP proposes a framework for flexible permission and role management in Ethereum smart contracts.
In a bit-based approach, each bit represents an independent permission. A 256-bit unsigned integer (uint256) can therefore represent a large number of permission combinations.
The system can express distinct bitmask combinations, including the empty combination. Each role can represent a different combination of permissions. This provides a flexible way to manage complex authorization requirements in large projects and applications with sophisticated business logic.
For example, one role can grant permission to call transfer, while another can grant permission to call mint. Developers can restrict particular operations to specific groups of users.
The proposal aims to make smart contract permission management more granular, flexible, and efficient. Actual security depends on the implementation and the correct enforcement of permissions.
Specification
The following interface uses Solidity 0.8.7 or later syntax. A conforming contract must implement it.
pragma solidity ^0.8.7;
/**
@title EIP-6617 Bit Based Permission
@dev See https://eips.ethereum.org/EIPS/eip-6617
*/
interface IEIP6617 {
/**
MUST trigger when a permission is granted.
@param _grantor Grantor of the permission
@param _permission Permission that is granted
@param _user User who received the permission
*/
event PermissionGranted(address indexed _grantor, uint256 indexed _permission, address indexed _user);
/**
MUST trigger when a permission is revoked.
@param _revoker Revoker of the permission
@param _permission Permission that is revoked
@param _user User who lost the permission
*/
event PermissionRevoked(address indexed _revoker, uint256 indexed _permission, address indexed _user);
/**
@notice Check if user has permission
@param _user Address of the user whose permission we need to check
@param _requiredPermission The required permission
@return True if the _permission is a superset of the _requiredPermission else False
*/
function hasPermission(address _user, uint256 _requiredPermission)
external
view
returns (bool);
/**
@notice Add permission to user
@param _user Address of the user to whom we are going to add a permission
@param _permissionToAdd The permission that will be added
@return The new permission with the _permissionToAdd
*/
function grantPermission(address _user, uint256 _permissionToAdd)
external
returns (bool);
/**
@notice Revoke permission from user
@param _user Address of the user to whom we are going to revoke a permission
@param _permissionToRevoke The permission that will be revoked
@return The new permission without the _permissionToRevoke
*/
function revokePermission(address _user, uint256 _permissionToRevoke)
external
returns (bool);
}Contracts conforming to EIP-6617 must implement the IEIP6617 interface.
Permissions are represented as uint256 values. Each individual permission occupies exactly one bit and must therefore be a power of two. Individual permissions must be unique, and 0 denotes the absence of permissions.
Metadata Interface
/**
* @dev Defined the interface of the metadata of EIP6617, MAY NOT be implemented
*/
interface IEIP6617Meta {
/**
Structure of permission description
@param _permission Permission
@param _name Name of the permission
@param _description Description of the permission
*/
struct PermissionDescription {
uint256 permission;
string name;
string description;
}
/**
MUST trigger when the description is updated.
@param _permission Permission
@param _name Name of the permission
@param _description Description of the permission
*/
event UpdatePermissionDescription(uint256 indexed _permission, string indexed _name, string indexed _description);
/**
Returns the description of a given `_permission`.
@param _permission Permission
*/
function getPermissionDescription(uint256 _permission) external view returns (PermissionDescription memory description);
/**
Return `true` if the description was set otherwise return `false`. It MUST emit `UpdatePermissionDescription` event.
@param _permission Permission
@param _name Name of the permission
@param _description Description of the permission
*/
function setPermissionDescription(uint256 _permission, string memory _name, string memory _description)
external
returns (bool success);
}IEIP6617Meta is an optional extension providing additional information about permissions in EIP-6617 contracts.
It allows contracts to define names and descriptions for individual permissions and important combinations, helping developers and users understand their meaning and intended behavior.
Providing a separate description for every possible combination is not recommended. The number of combinations is too large for exhaustive documentation to be practical.
Instead, describing individual permissions and meaningful combinations makes the overall authorization model easier to understand.
Implementing IEIP6617Meta improves transparency by communicating the purpose of permissions, helping users and developers manage the contract more effectively.
Additional Notes
Existing approaches to Ethereum smart contract permission management include the single-owner model defined by ERC-173 and role-based models using bytes32 identifiers, such as ERC-5982.
In the ERC-173 model, ownership identifies a single account (owner) responsible for the associated ownership privileges. ERC-5982 represents distinct roles using bytes32 values.
See the following article for ERC-173.
[ERC-173] Managing Smart Contract Ownership
See the following article for ERC-5982.
[ERC-5982] Role-Based Access Control
Bitwise operations and bitmasks offer several advantages.
Bitwise operations are inexpensive, potentially reducing contract execution costs. This can be particularly useful for applications with many users or permissions.
Bitmasks also provide flexibility: individual permission bits can be set or cleared independently, allowing developers to construct precise authorization rules.
Compared with single-owner or conventional role-based models, the bitmask representation can offer both efficiency and flexibility. These benefits depend on storage layout and how authorization checks are implemented.
Gas Efficiency
Bitwise operations are inexpensive and fast. For example, applying a bitwise AND to an already loaded permission mask can be considerably cheaper than performing several storage reads.
Flexibility
The 256 bits of a uint256 can represent up to 256 individual permissions, with combinations representing roles.
Roles need not all be defined in advance. Multiple permission masks can be combined using the bitwise OR operator to create a new role.
Ordering Permissions by Importance
Developers may assign more significant bits to permissions they consider more important. Since permissions use uint256, numerical comparisons are straightforward.
However, numerical ordering alone does not establish whether one permission mask contains all permissions in another. That requires the appropriate bitwise containment check.
Associating Semantic Meaning
Compared with the access-control model in ERC-5982, a numerical bitmask does not directly communicate the meaning of its permissions or roles. Metadata and documentation can help address this limitation.
Implementation
The reference implementation is available below.
https://eips.ethereum.org/assets/eip-6617/contracts/EIP6617.sol
Citation
Chiro (@chiro-hiro), Victor Dusart (@vdusart), "ERC-6617: Bit Based Permission [DRAFT]," Ethereum Improvement Proposals, no. 6617, February 2023. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-6617.
Conclusion
ERC-6617 proposes bit-based permission management for Ethereum smart contracts.
If you have questions, feel free to contact me on Twitter.
I also publish articles on the following platforms.


