Skip to main content

Use case: Inventory

This page explains how developers can utilise the Unity zkEVM API package to list gamers' NFTs in the game's inventory, enhancing the overall gaming experience.


To display a gamer NFT inventory, you can use the Search NFTs endpoint.

using System.Collections.Generic;
using Immutable.Api.ZkEvm.Api;
using Immutable.Api.ZkEvm.Client;

private readonly MetadataSearchApi m_MetadataSearchApi =
new(new Configuration { BasePath = "https://api.sandbox.immutable.com" }); // Or "https://api.immutable.com"

var result = await m_MetadataSearchApi.SearchNFTsAsync(
"imtbl-zkevm-testnet", // Or "imtbl-zkevm-mainnet"
contractAddress: new List<string> { "NFT_CONTRACT_ADDRESS" }, // Replace with the NFT contract address
accountAddress: "GAMER_WALLET_ADDRESS", // Replace with the gamer's wallet address
onlyIncludeOwnerListings: true // Set to true to only include listings by the owner
);

You can view an example of an inventory in the sample game here, which also utilises the Search NFTs endpoint. This example builds upon the concepts presented in the Build a game with Unity tutorial.