Rating Module

on-chain reputation system.

Created: 1/9/2026

Rating Module (rating_module)

The rating_module provides a persistent, on-chain reputation system for all users (both posters and workers).

Storage Structure

It uses a Table to store a UserRatings resource for every user address:

struct UserRatings has store {
    ratings: vector<u8>,       // History of scores (1-5)
    comments: vector<String>,  // IPFS hashes of comments
    average: u64,              // Running average (scaled x10)
}

Flows

Submitting a Rating

  • Restricted: This function is friend visibility only, meaning it can predominantly only be called by the gig_contract after a job is completed.
  • Logic:
    • Adds the new rating to the user's history.
    • Updates the running weighted average immediately.

Viewing Reputation

  • Function: get_average(user_addr).
  • Logic: Returns the scaled average (e.g., 45 represents 4.5 stars).
  • Usage: Frontends can query this to display user trust scores before engaging in a gig.