Skip to content

daniel-kolawole/Moving-Service-Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

Moving Service Marketplace Smart Contract

A robust Clarity smart contract for a decentralized moving service marketplace built on the Stacks blockchain. This contract enables movers to register their services, customers to book moves, and facilitates secure transactions with rating and review functionality.

Overview

The Moving Service Marketplace contract provides a complete platform for:

  • Mover Registration: Service providers register with their service type and hourly rates
  • Customer Management: Customers create profiles and book moving services
  • Booking System: Full lifecycle management from creation to completion
  • Payment Handling: Secure STX token transactions
  • Rating System: 5-star rating system with weighted average calculations
  • Service Quality: Track mover performance and customer satisfaction

Features

1. Mover Management

  • Register as a mover with service type and hourly rate
  • Deactivate/reactivate mover status
  • Track total jobs completed and average rating
  • View mover profile information

2. Customer Management

  • Register as a customer
  • View booking history
  • Track total bookings made

3. Booking System

  • Create bookings with specific movers
  • Accept/reject bookings (mover action)
  • Complete bookings after service delivery
  • Cancel pending bookings (customer action)
  • Automatic payment transfer on completion

4. Rating & Reviews

  • Rate completed bookings (1-5 stars)
  • Leave detailed reviews
  • Automatic rating aggregation
  • Track mover reputation

Data Structures

Mover Profile

``` { name: string, service-type: string, hourly-rate: uint (in microSTX), active: boolean, total-jobs: uint, total-rating: uint, rating-count: uint } ```

Customer Profile

``` { name: string, total-bookings: uint } ```

Booking

``` { customer: principal, mover: principal, hours: uint, total-cost: uint, status: string (pending/accepted/completed/cancelled), created-at: uint (block height), rating: uint (0-5, 0 if not rated), review: string } ```

Function Reference

Mover Functions

register-mover(name, service-type, hourly-rate)

Register as a mover in the marketplace.

  • Parameters:
    • name: Mover's business name (non-empty string)
    • service-type: Type of moving service (non-empty string)
    • hourly-rate: Rate in microSTX per hour (positive uint)
  • Returns: (ok true) on success
  • Errors: ERR-ALREADY-REGISTERED, ERR-INVALID-INPUT

deactivate-mover()

Deactivate your mover account.

  • Returns: (ok true) on success
  • Errors: ERR-NOT-REGISTERED

activate-mover()

Reactivate your mover account.

  • Returns: (ok true) on success
  • Errors: ERR-NOT-REGISTERED

Customer Functions

register-customer(name)

Register as a customer in the marketplace.

  • Parameters:
    • name: Customer's name (non-empty string)
  • Returns: (ok true) on success
  • Errors: ERR-ALREADY-REGISTERED, ERR-INVALID-INPUT

Booking Functions

create-booking(mover, hours)

Create a new booking with a mover.

  • Parameters:
    • mover: Principal address of the mover
    • hours: Number of hours needed (positive uint)
  • Returns: (ok booking-id) on success
  • Errors: ERR-NOT-REGISTERED, ERR-MOVER-NOT-FOUND, ERR-MOVER-INACTIVE, ERR-INVALID-INPUT

accept-booking(booking-id)

Accept a pending booking (mover action).

  • Parameters:
    • booking-id: ID of the booking to accept
  • Returns: (ok true) on success
  • Errors: ERR-BOOKING-NOT-FOUND, ERR-INVALID-STATUS, ERR-UNAUTHORIZED

complete-booking(booking-id)

Mark a booking as completed and transfer payment (mover action).

  • Parameters:
    • booking-id: ID of the booking to complete
  • Returns: (ok true) on success
  • Errors: ERR-BOOKING-NOT-FOUND, ERR-INVALID-STATUS, ERR-UNAUTHORIZED, ERR-INSUFFICIENT-BALANCE

cancel-booking(booking-id)

Cancel a pending booking (customer action).

  • Parameters:
    • booking-id: ID of the booking to cancel
  • Returns: (ok true) on success
  • Errors: ERR-BOOKING-NOT-FOUND, ERR-INVALID-STATUS, ERR-UNAUTHORIZED

Rating Functions

rate-booking(booking-id, rating, review)

Rate and review a completed booking.

  • Parameters:
    • booking-id: ID of the completed booking
    • rating: Rating from 1-5 stars
    • review: Review text (non-empty string)
  • Returns: (ok true) on success
  • Errors: ERR-BOOKING-NOT-FOUND, ERR-INVALID-STATUS, ERR-UNAUTHORIZED, ERR-INVALID-INPUT

Query Functions

get-mover(mover-principal)

Retrieve mover profile information.

  • Returns: Mover profile or none

get-customer(customer-principal)

Retrieve customer profile information.

  • Returns: Customer profile or none

get-booking(booking-id)

Retrieve booking details.

  • Returns: Booking details or none

get-mover-rating(mover-principal)

Get average rating for a mover.

  • Returns: Average rating (0-5) or none

Error Codes

Code Name Description
401 ERR-NOT-REGISTERED User is not registered as mover or customer
402 ERR-INSUFFICIENT-BALANCE Insufficient STX balance for payment
403 ERR-INVALID-INPUT Invalid input parameters (empty strings, invalid amounts)
404 ERR-NOT-FOUND Mover, customer, or booking not found
405 ERR-ALREADY-REGISTERED User already registered
406 ERR-MOVER-NOT-FOUND Specified mover not found
407 ERR-MOVER-INACTIVE Mover is not active
408 ERR-BOOKING-NOT-FOUND Booking not found
409 ERR-INVALID-STATUS Booking status doesn't allow this action
410 ERR-UNAUTHORIZED Caller not authorized for this action
422 ERR-INVALID-RATING Rating must be between 1 and 5

Usage Example

;; 1. Mover registers
(contract-call? .moving-marketplace register-mover "FastMove Inc" "Local Moving" u50000000)

;; 2. Customer registers
(contract-call? .moving-marketplace register-customer "John Doe")

;; 3. Customer creates booking (3 hours)
(contract-call? .moving-marketplace create-booking 'SP2MFRYGWESM5YBPQWYGNUC6YNXNTQC23DP2QE5Q u3)

;; 4. Mover accepts booking
(contract-call? .moving-marketplace accept-booking u0)

;; 5. Mover completes booking (payment transferred)
(contract-call? .moving-marketplace complete-booking u0)

;; 6. Customer rates the service
(contract-call? .moving-marketplace rate-booking u0 u5 "Excellent service!")

;; 7. Check mover rating
(contract-call? .moving-marketplace get-mover-rating 'SP2MFRYGWESM5YBPQWYGNUC6YNXNTQC23DP2QE5Q)

About

The Moving Service Marketplace is a decentralized smart contract built on the Stacks blockchain using Clarity. It creates a trustless, peer-to-peer platform connecting professional movers with customers who need moving services.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors