Gaming sdk
Inventory

Overview

Inventory is a set of items belonging to user. Skins, lootboxes, boosters are inventory items. Each item has it's own categories.

Inventory

To create your own item, first deploy the category smartcontract

  contract MyGameWeapon is InventoryCategoryNFT {
      string public override name = "Weapon";
      string public override description = "Game weapons";
      string public override imageUrl = "http://example.com/weapon_category.webp";
  }

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

  contract MyGameDiamondSword is InventoryItemNFT {
      string public override name = "Diamond sword";
      string public override description = "Shiny diamond sword";
      string public override imageUrl = "http://example.com/sword.webp";
      address[] public override categories = [0xA7c81c7c10be53974510911F44AF976c7D0709D9];
      bool public override transferable = true;
  }

After contract deployment you can mint item for user

  await gamingSdk.user.inventory.mint(SWORD_ADDRESS, 1);

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) => {...});