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

説明

🏆 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


ハッカソンの進行状況

Usage of GitHub and Flow

テックスタック

Web3
Solidity
Ethers
Next
React
Node
Move
Rust

資金調達の状況

na

チームリーダー
AAffan Latif
オープンソース
業界
SocialFiDeFiInfra