Mythical Platform
Mythical Platform
  • The Mythical Platform API
  • Quick start
    • Authenticate
    • Create a guest player
    • Create an item type
    • Grant an item to a player
    • Update item metadata
    • Use webhooks for real time messages
    • Buy a listed item
  • API Reference
    • Players
    • Item Types
    • Items
    • Marketplace
      • Listings
      • Offers
      • Quick trade
      • Transaction history
      • Exchange rate
    • Webhook management
    • System
Powered by GitBook
On this page
  1. Quick start

Create an item type

PreviousCreate a guest playerNextGrant an item to a player

Last updated 6 months ago

Before an item can be granted, you must define the item type. An item type is the blueprint from which individual items can be created. On-chain, item types are collections from which NFTs are minted.

Item types have the following characteristics:

collectionName

The name of the collection on-chain. This is an identifier which helps ensure you're looking at the right asset on the block explorer. It's not displayed in the Mythical Marketplace. This is immutable.

maxSupply

The maximum quantity of the item which can be granted.

mintMode

Determines how the tokenId of each item is selected when it is minted.

  • serial: Each consecutive tokenId is incremented from the previous.

  • random: Each consecutive tokenId is a random number between 1 and the maxSupply.

  • controlled: The tokenId is input when the item is minted.

defaultMetadata

Item metadata is linked to the item on-chain and displayed in the Mythical Marketplace. Default item metadata is set when no metadata is provided when the item is granted. See item metadata below.

The following image shows an item listed in the Mythical Marketplace. Note how metadata is displayed.

Item metadata has the following characteristics:

name

The title of the asset, "Christian McCaffrey"

description

A long form description of the asset, "RB for the 49ers"

image

A thumbnail style image representing the asset.

attributes

A list of attributes which describe the asset. These should be used for attributes that convey asset value. Examples could be rarity, strength, level, etc.

Creating an item type means a collection will be created on-chain.

// Define the new item type we want to create
const newItemType = {
  "collectionName": "collectionName", // displayed in block explorer
  "maxSupply": 1000, // no more than 1000 can be minted
  "mintMode": "serial", // token id will increment
  // default metadata will be used for new items if none is provided
  // item metadata is displayed in the marketplace
  "defaultMetadata": {
    "name": "itemName",
    "description": "itemDescription",
    "image": "http://url.com/image",
    "attributes": [
      {
        "type": "attribute1",
        "value": 10,
        "displayType": "number",
        "maxValue": 100
      },
      {
        "type": "attribute2",
        "value": "value",
        "displayType": "string"
      }
    ]
  }
}

// Create item type, causing a collection to be created on-chain
const response = await fetch('/v1/item-types', {
    method: 'POST',
    headers: {
      "x-mythical-environment-id": "123e4567-e89b-12d3-a456-426614174000",
      "Content-Type": "application/json"
    },
    body: JSON.stringify(newItemType),
});

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

console.log(
  id,   // f4e5d3a4-2a9b-4d9f-bc5a-73b3f0c47b5e -> will be used to grant items of this item type
  state // pending -> will send a webhook when the collection is created on-chain
) 

Once the item type is created, items can be granted.

An item listed in the Mythical Marketplace