Create collection items

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

import { HandCashMinter, Types } from "@handcash/handcash-connect";
import pLimit from "p-limit";

const handCashMinter = HandCashMinter.fromAppCredentials({
  appId: 'your-app-id',
  authToken: 'your-business-wallet-auth-token',

const jsonData = fs.readFileSync('./assets/dummy/collectionInfo.json', 'utf8');
const collectionDefinition = await handCashMinter.loadItemsFromJson(jsonData);
const collectionId = '...'; // Id from a previously create order to inscribe a collection

console.log(`⏳ Creating mint order of type collectionItems...`);
let order = await handCashMinter.createCollectionItemsOrder(collectionId);
console.log(`- ✅ Mint order created. Order ID: ${}`);

console.log(`- ⏳  Adding ${collectionDefinition.collection.totalQuantity} items to the order...`);
for (const itemMetadata of collectionDefinition.items) {
  const items = new Array(itemMetadata.quantity).fill(0).map(() => itemMetadata.item);
  console.log(`- ⏳  Adding ${itemMetadata.quantity} unit(s) of item named ${}...`);
	await handCashMinter.addOrderItems({
    itemCreationOrderType: 'collectionItem'
console.log('- ✅  Items added to mint order');

order = await handCashMinter.commitOrder(;
console.log('- ✅ Mint order committed');

console.log(`- ⏳ Paying ${order.payment.amountInUSD} USD to inscribe all the items on-chain...`);
const paymentResult = await handCashMinter.payPaymentRequest(order.payment.paymentRequestId);
console.log(`- ✅ Order paid. TransactionId: ${paymentResult.transactionId}`);
order = await handCashMinter.getOrder(;

while (order.pendingInscriptions > 0) {
  console.log(`- ⏳ Inscribing items. ${order.pendingInscriptions} pending inscriptions...`);
  order = await handCashMinter.inscribeNextBatch(;
const items = await handCashMinter.getOrderItems(;
console.log({ items });
console.log(`- ✅ All items inscribed`);