📚 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
-
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.
-
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.
-
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.
-
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!
📚 Overview
Develop a standalone FundRequest smart contract in
budgetchain-app/onchaindirectory 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
Data Structures & Storage
FundRequeststruct with the following fields:project_id: u64milestone_id: u64amount: u128requester: ContractAddressstatus: FundRequestStatus(enum with valuesPending,Approved,Rejected)FundsRequestedwith fieldsproject_id,request_id,milestone_idFundsReleasedwith fieldsproject_id,request_id,milestone_id,amountFundsReturnedwith fieldsproject_id,amount,project_ownerFunction 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.Validation & Access Control
Event Emission
FundsRequestedwhen a fund request is created.FundsReleasedwhen funds are successfully released.FundsReturnedif funds need to be returned.❗ Technical Considerations
Let's ensure this contract adds robust and secure fund request handling to the project!