hackquest logo

Achivements

he ReputationTracker smart contract is a simple yet powerful example of how blockchain technology can be used to store and manage user achievements in a transparent and decentralized way. It is design

Description

šŸ† Reputation / Achievement Tracker

A simple Solidity smart contract that tracks user reputation points, achievements, and badges on-chain.
It introduces key Solidity concepts such as mappings, structs, arrays, and events.


šŸ“œ Description

The ReputationTracker contract allows users to:

  • Earn points for actions

  • Unlock achievements

  • Receive badges stored on-chain

  • Retrieve their entire reputation profile anytime

This is a great beginner-to-intermediate Solidity project to understand user data storage and interaction within a contract.


āš™ļø Contract Details

  • Contract Name: ReputationTracker

  • Solidity Version: ^0.8.0

  • License: MIT

  • Contract Address - 0xb4c728e50ffB830F9ab5E01E17cacB9D1B76aE18 0xb4c728e50ffB830F9ab5E01E17cacB9D1B76aE18


šŸ’» Contract Code

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

contract ReputationTracker {
    struct User {
        uint points;
        uint achievements;
        string[] badges;
    }

    mapping(address => User) public users;

    event PointsAdded(address indexed user, uint newPoints);
    event AchievementUnlocked(address indexed user, string badgeName);

    function addPoints(uint _points) public {
        users[msg.sender].points += _points;
        emit PointsAdded(msg.sender, users[msg.sender].points);
    }

    function unlockBadge(string memory _badgeName) public {
        users[msg.sender].achievements += 1;
        users[msg.sender].badges.push(_badgeName);
        emit AchievementUnlocked(msg.sender, _badgeName);
    }

    function getUser(address _user) public view returns (uint, uint, string[] memory) {
        User storage user = users[_user];
        return (user.points, user.achievements, user.badges);
    }
}

🧠 Key Concepts

Concept

Description

Struct

Combines multiple related variables (points, achievements, badges) into one type

Mapping

Associates each user (address) with their User struct

Event

Emits logs for on-chain actions (like adding points or unlocking badges)

Dynamic Array

Stores multiple badges for each user


šŸš€ How to Use (Remix IDE)

  1. Open Remix IDE

  2. Create a new file named ReputationTracker.sol

  3. Paste the contract code above

  4. Compile using Solidity 0.8.x

  5. Deploy the contract

  6. Interact with the following functions:

Function

Description

addPoints(uint _points)

Adds points to your account

unlockBadge(string _badgeName)

Adds an achievement badge

getUser(address _user)

Retrieves full user data (points, achievements, badges)


🧩 Example Usage

Action

Input

Result

addPoints(50)

—

points = 50

unlockBadge("First Task Completed")

—

achievements = 1, badges = ["First Task Completed"]

getUser(<your_address>)

—

Returns (50, 1, ["First Task Completed"])


šŸ”„ Possible Extensions

  • Add a function to transfer reputation between users

  • Add admin-only access for awarding points

  • Add leaderboard logic for top users

  • Integrate with a frontend (React + Web3.js) for a gamified UI


Progress During Hackathon

Usage of GitHub and Flow

Tech Stack

Web3
Solidity
Ethers
Next
React
Node
Move
Rust

Fundraising Status

na

Team LeaderAAffan Latif
Sector
SocialFiDeFiInfra

Builders Also Viewed