Create collection items

The following code shows how to use the HandCash Minter to inscribe the collection items on-chain.

import dotenv from 'dotenv';
import { HandCashMinter } from '@handcash/handcash-connect';

dotenv.config();

const handCashMinter = HandCashMinter.fromAppCredentials({
  appId: process.env.HANDCASH_APP_ID,
  authToken: process.env.HANDCASH_AUTH_TOKEN,
});

(async () => {

  const collectionId = "657762fc2acbecc109d8c1fb";

  const creationOrder = await handCashMinter.createItems(collectionId,
    [
      {
        user: "612cba70e108780b4f6817ad",
        name: "Rafa",
        rarity: "Mythic",
        attributes: [
          { name: "Edition", value: "Test", displayType: "string" },
          { name: "Generation", value: "1", displayType: "string" },
          { name: "Country", value: "Spain", displayType: "string" }
        ],
        mediaDetails: {
          image: {
            url: "https://res.cloudinary.com/handcash-iae/image/upload/v1702398977/items/jyn2qqyqyepqhqi9p661.webp",
            imageHighResUrl: "https://res.cloudinary.com/handcash-iae/image/upload/v1697465892/items/zq0lupxoj8id1uedgz2h.png",
            contentType: "image/webp"
          }
        },
        color: "#bf9078",
        quantity: 3
      },
      {
        user: "6213a44bf2936f711c8d19d3",
        name: "Alex",
        rarity: "Mythic",
        attributes: [
          { name: "Edition", value: "Test", displayType: "string" },
          { name: "Generation", value: "1", displayType: "string" },
          { name: "Country", value: "Andorra", displayType: "string" }
        ],
        mediaDetails: {
          image: {
            url: "https://res.cloudinary.com/handcash-iae/image/upload/v1702398906/items/da2qv0oqma0hs3gqevg7.webp",
            imageHighResUrl: "https://res.cloudinary.com/handcash-iae/image/upload/v1697465892/items/gh7tsn11svhx7z943znv.png",
            contentType: "image/webp"
          }
        },
        color: "#73c9ac",
        quantity: 3
      },
      {
        name: "Brandon Bryant",
        rarity: "Mythic",
        attributes: [
          { name: "Edition", value: "Test", displayType: "string" },
          { name: "Generation", value: "2", displayType: "string" },
          { name: "Country", value: "United States", displayType: "string" }
        ],
        mediaDetails: {
          image: {
            url: "https://res.cloudinary.com/handcash-iae/image/upload/v1702398906/items/da2qv0oqma0hs3gqevg7.webp",
            imageHighResUrl: "https://res.cloudinary.com/handcash-iae/image/upload/v1697465892/items/edaoeseq43yqdbqwjzn4.png",
            contentType: "image/webp"
          }
        },
        color: "#adeaf5",
        quantity: 1
      }
    ]);

  console.log(`Items order created, items are being created asynchronously`)
})();