hackquest logo
  • Aprender
  • Explorar curso
  • Construir
  • Explorar hackatón
  • Archivo de proyectos
  • Comunidad
  • Foro
  • Evento global
  • Mi comunidad
  • Aprendizaje conjunto
  • Centro de organización
  • Más
    • Glosario
    • Blog
    • Grifos
    • Estación de trabajo
    • Kit de prensa
    • Fundador
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

Pila tecnológica

Web3
Solidity
Ethers
Next
React
Node
Move
Rust

Descripción

🏆 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 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


📄 License

This project is licensed under the MIT License.

Progreso del hackathon

Usage of GitHub and Flow

Estado de recaudación de fondos

na
Líder del equipo
AAffan Latif
Enlace del proyecto
Sector
SocialFiDeFiInfra