import { HandCashConnect, HandCashMinter } from '@handcash/handcash-connect';
const handCashConnect = new HandCashConnect({
appId: '<app-id>',
appSecret: '<secret>',
});
const handCashMinter = HandCashMinter.fromAppCredentials({
appId: process.env.HANDCASH_APP_ID,
authToken: process.env.HANDCASH_AUTH_TOKEN,
appSecret: process.env.HANDCASH_APP_SECRET
});
async function craftItems(collectionId: string) {
// Get items from user's inventory
const handcashAccount = await handCashConnect.getAccountFromAuthToken('<user-auth-token>');
let items = await handcashAccount.items.getItemsInventory({
searchString: 'Rafa',
collectionId,
groupingValue: '0df774cab8b1c51d6d74fccd577fe436'
});
const itemsToBurn = items.slice(0, 2);
// Define the new item to create
const itemToCreate = {
// Define your new item properties here
};
// Burn 2 "Rafa" items to craft 1 "Alex" item
let burnOrderResult = await handCashMinter.burnAndCreateItemsOrder({
burn: {
origins: itemsToBurn.map((item: any) => item.origin),
},
issue: {
items: [itemToCreate],
collectionId: collectionId,
}
});
console.log('Craft Order Result:', burnOrderResult);
}