A Web3.0 Project Built for Encode Lightlink Hackathon.
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.
- For Players:
- Go to ChainXP and connect your wallet.
- Click on the settings button and fill in your details and choose avatar.
- Go to the home page and choose a game.
- Check for any ongoing challenges and join in as per your eligibility.
- Go to the Game's "How to Play" link and play the game.
- If you fail the challenge and still have some tries left, pay extra fees and re-join on ChainXP.
- If you complete the challenge within the time duration, you get XP tokens as the reward.
- For Developers:
- Go to ChainXP and connect your wallet.
- Click on the settings button and fill in your details and choose avatar.
- Go to the Dev Mode tab and register your ChainXP Compatible(see below) game contract.
- Click on the add quest button to create a new quest.
- Call the smart contract methods from the frontend whenever a player completes/fails in a quest.
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);
}
}- 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
- Game Earnings: Total amount of XP earned by a particular game.
- Current Level:
(gameEarnings/100)+1 - Quest Bonus:
(currentLevel-1)*10This bonus is given everytime a user completes a quest. - Rejoining Fees:
(enterFees)*triesTakenThe more tries you take, the higher is the re-joining fees.
