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.
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
- 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-OWNER (Level 1): Full administrative rights
- Assign/revoke access levels
- Validate expenditures
- Record expenditures
- ACCESS-MANAGER (Level 2): Project management rights
- Create new projects
- ACCESS-PARTICIPANT (Level 3): Basic participant rights
- View project information
- Fund projects (anyone can fund, regardless of access level)
create-project(title, details, funding-goal)- Create a new funding projectget-project(id)- Retrieve project information by ID
fund-project(project-id, value)- Contribute STX to a projectget-contribution-by-id(contribution-id)- Get contribution detailsget-contribution-total()- Get total number of contributions
record-expenditure(project-id, details, value)- Record project expensevalidate-expenditure(project-id, phase)- Approve recorded expenditureget-expenditure-by-id(expenditure-id)- Get expenditure detailsget-expenditure-total()- Get total number of expenditures
assign-access(account, new-level)- Grant access level to userrevoke-access(account)- Remove user's access level
{
title: string-utf8 50,
details: string-utf8 255,
funding-goal: uint,
funds-raised: uint,
state: string-ascii 20
}{
contributor: principal,
project-id: uint,
value: uint,
block-time: uint
}{
project-id: uint,
phase: uint,
details: string-utf8 255,
value: uint,
state: string-ascii 20
}u100- Unauthorized access attemptu101- Duplicate entry erroru102- Entry not foundu103- Insufficient balanceu104- Project not foundu105- Expenditure not foundu106- Invalid input parameters
- 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
- Deploy Contract: Admin automatically receives ACCESS-OWNER level
- Assign Managers:
(assign-access 'SP1ABC... ACCESS-MANAGER) - Create Project:
(create-project "Mobile App" "Revolutionary new app" u1000000) - Fund Project:
(fund-project u1 u50000) - Record Expense:
(record-expenditure u1 "Development costs" u25000) - Validate Expense:
(validate-expenditure u1 u1)
- 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
- 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