Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add on-chain service rating system for subscription services#3

Open
Clawue884 wants to merge 8 commits into
PiNetwork:main from
Clawue884:main
Open

Add on-chain service rating system for subscription services #3
Clawue884 wants to merge 8 commits into
PiNetwork:main from
Clawue884:main

Conversation

@Clawue884

@Clawue884 Clawue884 commented Apr 17, 2026

Copy link
Copy Markdown

Summary

This PR introduces an on-chain service rating system for subscription services.

Subscribers can now rate services on a scale of 1 to 5, while the contract stores aggregate rating data on-chain.
This adds a lightweight reputation layer to merchant services without affecting the existing subscription workflow.


Features Added

New Rating Model

Introduced a new ServiceRating struct to store:

  • total_score
  • total_raters

This enables calculation of average ratings on-chain.


New Storage Keys

Added new persistent storage entries:

  • ServiceRating(service_id)
    Stores aggregate rating data for each service.

  • RatingGiven(subscriber, service_id)
    Prevents duplicate ratings by the same subscriber.


New Contract Methods

rate_service(...)

Allows a subscriber to rate a service from 1 to 5.

Validation includes:

  • service must exist
  • score must be between 1 and 5
  • duplicate ratings are rejected

On success:

  • updates aggregate rating
  • records subscriber rating status
  • emits a rate event

get_service_rating(...)

Returns the aggregate rating data for a service:

  • total_score
  • total_raters

Average rating can be derived as:

average = total_score / total_raters


Error Handling

Added new contract errors:

  • InvalidRating
  • AlreadyRated

These ensure rating integrity and prevent invalid or duplicate submissions.


Benefits

This feature adds:

  • an on-chain reputation layer for services
  • merchant quality visibility
  • subscriber feedback transparency
  • groundwork for future ranking or reputation systems

Backward Compatibility

This PR is backward compatible:

  • existing subscription flows are unchanged
  • no breaking API changes
  • rating functions are fully additive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@Khus1996 Khus1996 Khus1996 approved these changes
Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /