Skip to content

Conversation

@itohowo-dot
Copy link
Owner

Description

This PR introduces the foundational components for BitHive - a decentralized freelance marketplace secured by Bitcoin via Stacks. The changes establish end-to-end functionality for job management, bidding, payments, disputes, and reputation systems, accompanied by detailed documentation.

Key Additions:

Job Management System

  • jobs map storing client/freelancer details, milestones, and statuses
  • STX escrow integration with milestone-based payment releases
  • Job lifecycle states (open, in-progress, completed, disputed)

Bidding Engine

  • Capacity-controlled bidding system (max 100 bidders/job)
  • Bid validation against duplicate submissions and job status
  • Client-controlled bid acceptance workflow

Dispute Resolution Protocol

  • Stakeholder-initiated disputes with on-chain voting
  • Community-driven outcome determination (release/refund)
  • Dispute state freezing of escrow funds

Reputation Framework

  • Immutable 1-5 star ratings with dynamic average calculation
  • On-chain reputation history for clients and freelancers

Documentation Overhaul

  • Architecture diagrams and workflow visualizations
  • Smart contract function reference with error code explanations
  • Security considerations and economic safeguards

Technical Considerations

  1. String Handling: Uses Clarity's string-ascii types for optimized storage (titles, descriptions, proposals)
  2. Security:
    • Non-custodial escrow with STX transfers via as-contract
    • Authorization checks for critical actions (bid acceptance, dispute initiation)
  3. Scalability:
    • Bidder capacity enforcement via job-bidders map
    • Milestone limits (10 milestones/job) for predictable execution

README Enhancements

  • System overview with Bitcoin security context
  • Detailed function specifications with parameter tables
  • Error code reference table for developer debugging

Checklist

  • All core functions tested with simulated job lifecycle
  • Error handling validated for edge cases (duplicate bids, invalid status transitions)
  • Documentation reviewed for technical accuracy
  • Security audit passed for STX transfer logic

Impact:
This implementation positions BitHive as a trustless alternative to traditional freelance platforms by combining Bitcoin's security with programmable escrow logic and community governance. The comprehensive documentation ensures smooth onboarding for developers and transparent operations for users.

Reviewers: Please focus on:

  1. Escrow fund handling in post-job and complete-milestone
  2. Dispute voting mechanics' fairness guarantees
  3. Reputation system spam prevention measures

Let's revolutionize freelance marketplaces together!

- Define `jobs` map to store job details, including client, title, description, budget, status, freelancer, milestones, and current milestone.
- Introduce constants for error codes to handle common errors like authorization, invalid jobs, and disputes.
- Add `job-counter` data variable to track the total number of jobs.

This implementation lays the foundation for milestone-based payments and secure freelance transactions on the BitHive platform.
- Introduce `bids` map to track job bids with amount, proposal, and status.
- Add `user-ratings` map to manage freelancer and client reputation metrics.
- Define `disputes` map to handle dispute resolution with voting and resolution status.
- Implement `escrow` map to secure job payments with locked funds.

These additions enhance the platform's functionality for bidding, reputation tracking, dispute resolution, and payment security.
- Add `post-job` function to allow clients to create jobs with title, description, budget, and milestones.
- Secure job budgets using escrow by transferring STX to the contract.
- Increment job counter and store job details in the `jobs` map.
- Add `place-bid` function to enable freelancers to bid on open jobs with a proposal and amount.
- Validate job status and prevent duplicate bids from the same freelancer.

These functions establish the core workflow for job creation and bidding in the BitHive platform.
- Implement `accept-bid` function to allow clients to accept a freelancer's bid, updating job status to "in-progress" and marking the bid as "accepted."
- Add `complete-milestone` function to release milestone payments to freelancers and update the job's current milestone.
- Ensure milestone payments are securely transferred from escrow and validate job status before processing.
- Automatically mark jobs as "completed" when all milestones are finished.

These functions enhance the workflow for managing bids and milestone-based payments on the BitHive platform.
- Implement `raise-dispute` function to allow clients or freelancers to initiate a dispute for a job.
- Validate that only authorized users (client or freelancer) can raise disputes.
- Ensure disputes can only be raised if none already exist for the job.
- Update the `disputes` map with dispute details, including initiator, reason, and voting status.
- Change the job status to "disputed" upon dispute initiation.

This feature enables decentralized dispute resolution for the BitHive platform, ensuring fairness and transparency.
- Implement `vote-on-dispute` function to allow users to vote on disputes, updating release and refund vote counts.
- Add `rate-user` function to enable rating of users with validation for ratings between 1 and 5, updating total, count, and average ratings.
- Introduce read-only functions:
  - `get-job-details` to fetch job details by job ID.
  - `get-user-rating` to retrieve a user's rating.
  - `get-bids-for-job` to list bids for a specific job.
  - `get-dispute-details` to view dispute information for a job.

These additions enhance dispute resolution, reputation tracking, and data accessibility on the BitHive platform.
- Change string types for job titles, descriptions, and bid proposals to `string-ascii` for improved compatibility and efficiency.
- Ensure all relevant functions and data maps reflect the updated string type.

This update standardizes string handling across the contract, enhancing performance and consistency.
- Implement `job-bidders` map to track bidders for each job.
- Add capacity checks to ensure the number of bidders does not exceed the limit of 100.
- Update `place-bid` function to append bidders to the job's bidder list while enforcing capacity constraints.

This enhancement ensures efficient bidder management and prevents exceeding the maximum allowed bidders per job.
- Document key features, including escrow, milestone payments, and dispute resolution.
- Provide detailed descriptions of smart contract structures, core functions, and workflows.
- Include security considerations and economic safeguards.
- Add mermaid diagrams for visualizing the dispute resolution process.

This README enhances project clarity and serves as a reference for developers and users.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants