BudgetChain / BudgetChain/BudgetChain-Frontend

Implement AccessControl Contract for Role and Permission Management

Open
#96 4 comments 0 reactions 0 assignees View on GitHub
Cairo Language difficulty: medium ODHack14
Dominant language
TypeScript
Stars
8
Forks
34
PR merge metrics
No merged PRs in 30d

Description

## Overview

Develop a standalone AccessControl smart contract in `budgetchain-app/onchain` directory in Cairo to manage roles and permissions across the budget allocation system. This contract will provide secure role-based access control for admins, organizations, and project owners.

## Objectives

- Define role constants such as `DEFAULT_ADMIN_ROLE`, `ADMIN_ROLE`, and `ORGANIZATION_ROLE`.
- Set up storage for role assignments using an appropriate structure (e.g., a mapping of addresses to booleans).
- Implement core functions:
1. `grant_role`: Assign a role to an account.
2. `revoke_role`: Remove a role from an account.
3. `has_role`: Check if an account possesses a given role.
- Add internal checks to ensure that only authorized accounts can grant or revoke roles.
- Support role hierarchy as needed.
- Emit events for role changes (e.g., `RoleGranted`, `RoleRevoked`, `AdminAdded`).
- Integrate the contract with other contracts for permission verifications.
- Write comprehensive unit tests covering role management, access restrictions, and event emissions.
- Provide usage examples and document the contract interface for clarity.

## Technical Considerations

- Ensure proper event handling by emitting events whenever roles are granted or revoked.
- Maintain clear and secure internal access control checks to restrict functions to authorized accounts.
- Include detailed documentation and usage examples to facilitate integration with other contracts.

## Tasks

1. Define role constants and the storage structure for role assignments.
2. Implement the functions: `grant_role`, `revoke_role`, and `has_role`.
3. Add internal checks for role-restricted functions to ensure only authorized accounts can make changes.
4. Emit role-related events for each role change operation.
6. Document the contract interface and provide usage examples.

## Additional Resources

- For guidance on coding conventions or integration details, refer to the project's [README](https://github.com/BudgetChain/budgetchain-app?tab=readme-ov-file).

Let's ensure secure and transparent role management for the budget allocation system! 🚀

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.