Skip to content

parthg1901/chainXP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChainXP

A Web3.0 Project Built for Encode Lightlink Hackathon.

sample

Overview

Game Development is already a tedious task, and once we add a pinch of Web3 in it, it becomes even more tedious. Whether it be creating smart contracts, designing NFT assets or adding a reward mechanism, everything takes alot of time and resources. And even after all that, there's still no specific system for challenge-based games. One such solution is built by the Perion Team, which is xp.gg, which adds a XP token mechanism to some popular games. However, there should be something for new web3.0 developers too. ChainXP solves this problem by allowing new web3 games to integrate XP token mechanism to organise quests/challenges to their game without even a single line of code.

Usage

  • For Players:
  1. Go to ChainXP and connect your wallet.
  2. Click on the settings button and fill in your details and choose avatar.
  3. Go to the home page and choose a game.
  4. Check for any ongoing challenges and join in as per your eligibility.
  5. Go to the Game's "How to Play" link and play the game.
  6. If you fail the challenge and still have some tries left, pay extra fees and re-join on ChainXP.
  7. If you complete the challenge within the time duration, you get XP tokens as the reward.
  • For Developers:
  1. Go to ChainXP and connect your wallet.
  2. Click on the settings button and fill in your details and choose avatar.
  3. Go to the Dev Mode tab and register your ChainXP Compatible(see below) game contract.
  4. Click on the add quest button to create a new quest.
  5. Call the smart contract methods from the frontend whenever a player completes/fails in a quest.

ChainXP Compatible Contract

Your Game contract must be compatible with ChainXP. To do so, you just need to paste some extra lines of code! Here's a sample contract -

// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import "./IChainXP.sol";

contract SampleGame {
    address immutable owner;
    uint256 private gameId;
    IChainXP chainXP; 
    constructor() {
        owner=msg.sender;
    }
    // ...other game functions
    function addChainXP(IChainXP xp) external {
        require(msg.sender == owner);
        chainXP = xp;    
    }
    function setGameId(uint256 _gameId) external {
        require(msg.sender == owner);
        gameId = _gameId;
    }
    function questComplete(uint256 questId) external {
        chainXP.questComplete(msg.sender, gameId, questId);
    }
    function questFailed(uint256 questId) external {
        chainXP.questFailed(msg.sender, gameId, questId);
    }
}

How it's made

  • Framework - ReactJS
  • Smart Contract Interaction - Wagmi, Ethers.js, CCIP Read Protocol
  • Styling - Bootstrap
  • Environment - Hardhat
  • Deployment - Pegasus (Lightlink Enterprise Mode)
  • Gateway - Cloudflare
  • Database - Cloudflare D1
  • Database Querying - Kysely

Terminology

  • Game Earnings: Total amount of XP earned by a particular game.
  • Current Level: (gameEarnings/100)+1
  • Quest Bonus: (currentLevel-1)*10 This bonus is given everytime a user completes a quest.
  • Rejoining Fees: (enterFees)*triesTaken The more tries you take, the higher is the re-joining fees.

License

MIT

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •