Skip to content

suzanabel/Project-Funding-Smart-Contract

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

Project Funding Smart Contract

A decentralized project funding platform built on the Stacks blockchain using Clarity smart contracts. This contract enables transparent project creation, funding, and expenditure tracking with role-based access control.

Overview

This smart contract facilitates crowdfunding projects where:

  • Managers can create funding projects
  • Contributors can fund projects with STX tokens
  • Owners can track and validate project expenditures
  • All transactions are recorded transparently on-chain

Features

Core Functionality

  • Project Creation: Create projects with funding goals and descriptions
  • Decentralized Funding: Accept STX contributions from any wallet
  • Expenditure Tracking: Record and approve project expenses
  • Role-Based Access: Three-tier permission system
  • Transparent Records: All funding and spending is publicly verifiable

Access Levels

  1. ACCESS-OWNER (Level 1): Full administrative rights
    • Assign/revoke access levels
    • Validate expenditures
    • Record expenditures
  2. ACCESS-MANAGER (Level 2): Project management rights
    • Create new projects
  3. ACCESS-PARTICIPANT (Level 3): Basic participant rights
    • View project information
    • Fund projects (anyone can fund, regardless of access level)

Contract Functions

Project Management

  • create-project(title, details, funding-goal) - Create a new funding project
  • get-project(id) - Retrieve project information by ID

Funding Operations

  • fund-project(project-id, value) - Contribute STX to a project
  • get-contribution-by-id(contribution-id) - Get contribution details
  • get-contribution-total() - Get total number of contributions

Expenditure Tracking

  • record-expenditure(project-id, details, value) - Record project expense
  • validate-expenditure(project-id, phase) - Approve recorded expenditure
  • get-expenditure-by-id(expenditure-id) - Get expenditure details
  • get-expenditure-total() - Get total number of expenditures

Access Control

  • assign-access(account, new-level) - Grant access level to user
  • revoke-access(account) - Remove user's access level

Data Structures

Projects

{
  title: string-utf8 50,
  details: string-utf8 255,
  funding-goal: uint,
  funds-raised: uint,
  state: string-ascii 20
}

Contributions

{
  contributor: principal,
  project-id: uint,
  value: uint,
  block-time: uint
}

Expenditures

{
  project-id: uint,
  phase: uint,
  details: string-utf8 255,
  value: uint,
  state: string-ascii 20
}

Error Codes

  • u100 - Unauthorized access attempt
  • u101 - Duplicate entry error
  • u102 - Entry not found
  • u103 - Insufficient balance
  • u104 - Project not found
  • u105 - Expenditure not found
  • u106 - Invalid input parameters

Security Features

  • Role-based permissions: Prevents unauthorized actions
  • Input validation: Ensures data integrity
  • Overflow protection: Safe arithmetic operations
  • Self-modification protection: Users cannot modify their own access levels
  • Fund safety: STX tokens are held securely in contract

Usage Example

  1. Deploy Contract: Admin automatically receives ACCESS-OWNER level
  2. Assign Managers: (assign-access 'SP1ABC... ACCESS-MANAGER)
  3. Create Project: (create-project "Mobile App" "Revolutionary new app" u1000000)
  4. Fund Project: (fund-project u1 u50000)
  5. Record Expense: (record-expenditure u1 "Development costs" u25000)
  6. Validate Expense: (validate-expenditure u1 u1)

Deployment Notes

  • Contract admin is set to the deploying principal
  • Admin automatically receives ACCESS-OWNER permissions
  • All counters start at 0
  • Projects begin with "active" state
  • Expenditures begin with "pending" state

Security Considerations

  • Only contract admin can assign/revoke access levels
  • Expenditures require validation before approval
  • Cannot approve expenditures exceeding available funds
  • All role assignments are logged and traceable
  • Input validation prevents malformed data entry

About

The Project Funding Smart Contract is a decentralized crowdfunding platform built on the Stacks blockchain using Clarity. This contract enables transparent, trustless project funding with comprehensive expenditure tracking and role-based governance.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors