Grant an item to a player

To grant an item to a player, simply POST to /items, providing the new owner's playerId. If metadata is not provided, the default metadata configured on the item type will be used.

// Define the item we want to create
const newItem = {
  "itemTypeId": "f4e5d3a4-2a9b-4d9f-bc5a-73b3f0c47b5e",
  "ownerPlayerId": "9779f02d-5193-4ab1-ae15-f18e091f38e1"
  // Note: Because no metadata is being provided, the default
  // metadata from the item type will be used.
};

// Grant the item, causing an NFT to be minted on-chain. 
const response = await fetch('/v1/items', {
    method: 'POST',
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify(newItem),
});

const { id, state } = await response.json();

console.log(
  id, // 4fd615d5-7e29-4332-8b3b-3dc479e5f472 -> will be used to perform transactions with the item
  state // pending -> will send a webhook when the NFT is minted
) 

Granting an item means that an NFT will be minted from the defined collection to the players wallet on-chain. This is an asynchronous operation which can take several seconds. It’s handled differently by different apps:

  • In-game ownership is optimistic, meaning ownership is immediately reflected in the platform API. This ensures the player has a fast and seamless experience in-game.

  • Mythical Marketplace ownership is not optimistic, meaning ownership is reflected in marketplace inventory once the mint transaction finalizes on-chain, which can take several seconds. This ensures the player has a fault proof experience in the Mythical Marketplace.

Last updated