BudgetChain / BudgetChain/BudgetChain-Frontend

Implement Fund Request Contract for Project Milestones

Open
#99 5 comments 0 reactions 1 assignee Claimed by @davedumto View on GitHub
Cairo Language difficulty: medium good first issue ODHack14
Dominant language
TypeScript
Stars
8
Forks
34
PR merge metrics
No merged PRs in 30d

Description

## 📚 Overview
Develop a standalone FundRequest smart contract in `budgetchain-app/onchain` directory in Cairo to manage fund requests tied to project milestones. The contract will support request creation, approval, rejection, status tracking, and update project budgets accordingly. It is crucial that only completed milestones can have fund requests and that proper validations and access controls are in place.

## 🛠️ Requirements & Tasks

1. **Data Structures & Storage**
- Define a `FundRequest` struct with the following fields:
- `project_id: u64`
- `milestone_id: u64`
- `amount: u128`
- `requester: ContractAddress`
- `status: FundRequestStatus` (enum with values `Pending`, `Approved`, `Rejected`)
- Define events:
- `FundsRequested` with fields `project_id`, `request_id`, `milestone_id`
- `FundsReleased` with fields `project_id`, `request_id`, `milestone_id`, `amount`
- `FundsReturned` with fields `project_id`, `amount`, `project_owner`
- Set up storage for fund requests and counters.

2. **Function Implementation**
- `create_fund_request`: Allow project owners to create a fund request only for completedd milestones.
- `approve_fund_request`: Allow authorized organizations/admins to approve a fund request and release funds.
- `reject_fund_request`: Allow authorized organizations/admins to reject a fund request.
- Ensure that upon fund approval, the project budgets are updated accordingly.

3. **Validation & Access Control**
- Verify that only completed milestones can have fund requests.
- Implement proper validations for request statuses and access control for request lifecycle functions.

4. **Event Emission**
- Emit `FundsRequested` when a fund request is created.
- Emit `FundsReleased` when funds are successfully released.
- Emit `FundsReturned` if funds need to be returned.

## ❗ Technical Considerations
- Ensure the functions are secure and only callable by authorized roles.
- The implementation should handle edge cases such as invalid amounts or unauthorized accesses.
- Follow best practices regarding state management and event handling in smart contracts.

Let's ensure this contract adds robust and secure fund request handling to the project!

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.