Gaming sdk
Achievements

Overview

Achievement is a reward for user for reaching core gameplay points. Each achevement has it's own categories.


Achievements

To create your own item, first deploy the category smartcontract

  contract MyGameAchievement is AchievementCategoryNFT {
      string public override name = "Main achevements";
      string public override description = "Main game achevements";
      string public override imageUrl = "http://example.com/achevements.webp";
  }

Once category NFT is deployed, it's address is used as category identifier. Then you need to deploy the achevement NFT

  contract MyGameFirstBossAchievement is ItemNFT {
      string public override name = "Kill first boss";
      string public override description = "Given for the first boss killing";
      string public override imageUrl = "http://example.com/boss_achievement.webp";
      address[] public override categories = [0x5852c7605B69400a78aA85fA2Bc8f66a6B2b1295];
 
  }

After contract deployment you can mint achievement for user

  await gamingSdk.user.achevements.mint(user_address, MY_GAME_FIRST_BOSS_ACHIEVEMENT_ADDRESS);

Request user items by categories

const userInventory = await gamingSdk.user.current.inventory.get([WEAPON_CATEGORY_NFT_ADDRESS]);

Watch new items minted

  await gamingSdk.user.current.inventory.watch([WEAPON_CATEGORY_NFT_ADDRESS], (newItems) => {...});