Decentralized Dating Reputation

What it does:
Tracks and verifies dating interactions and reputation scores on-chain, providing transparent trust metrics for users in decentralized dating platforms.

Why it matters:
Reduces fraud, encourages honesty, increases trust between participants, and provides verifiable reputation data without relying on centralized platforms.

How it works:

  • Users create profiles with optional KYC or verification proofs

  • Interactions or dates can be rated and recorded by participants

  • Smart contract calculates reputation scores based on ratings, verified interactions, and historical behavior

  • Immutable records prevent fake reviews or manipulation

  • Integrates with Relationship Agreements, Personal Goal Accountability, or tokenized dating rewards

  • Dashboards display trust scores, verification badges, and interaction history

      // SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/access/Ownable.sol";

/**
 * @title DecentralizedDatingReputation
 * @author Nam
 * @notice Tracks dating interactions and calculates reputation scores on-chain
 */
contract DecentralizedDatingReputation is Ownable {

    struct Profile {
        string username;
        address user;
        uint256 totalScore;
        uint256 ratingCount;
        bool exists;
    }

    mapping(address => Profile) public profiles;
    mapping(address => bool) public authorizedValidators;

    // -------------------- EVENTS --------------------

    event ProfileCreated(address user, string username);
    event ValidatorApproved(address validator);
    event ValidatorRevoked(address validator);
    event InteractionRated(address user, address ratedBy, uint8 rating);
    event ReputationUpdated(address user, uint256 newScore);

    // -------------------- VALIDATOR MANAGEMENT --------------------

    function approveValidator(address _validator) external onlyOwner {
        authorizedValidators[_validator] = true;
        emit ValidatorApproved(_validator);
    }

    function revokeValidator(address _validator) external onlyOwner {
        authorizedValidators[_validator] = false;
        emit ValidatorRevoked(_validator);
    }

    modifier onlyValidator() {
        require(authorizedValidators[msg.sender], "Not authorized validator");
        _;
    }

    // -------------------- PROFILE MANAGEMENT --------------------

    function createProfile(string calldata _username) external {
        require(!profiles[msg.sender].exists, "Profile already exists");

        profiles[msg.sender] = Profile({
            username: _username,
            user: msg.sender,
            totalScore: 0,
            ratingCount: 0,
            exists: true
        });

        emit ProfileCreated(msg.sender, _username);
    }

    // -------------------- INTERACTION & REPUTATION --------------------

    function rateInteraction(address _user, uint8 _rating) external onlyValidator {
        require(_rating >= 1 && _rating <= 5, "Rating must be 1-5");
        Profile storage p = profiles[_user];
        require(p.exists, "Profile does not exist");

        p.totalScore += _rating;
        p.ratingCount += 1;

        emit InteractionRated(_user, msg.sender, _rating);
        emit ReputationUpdated(_user, getReputationScore(_user));
    }

    function getReputationScore(address _user) public view returns (uint256) {
        Profile storage p = profiles[_user];
        if (p.ratingCount == 0) return 0;
        return p.totalScore / p.ratingCount;
    }
}