Craft and Burn items
Overview
Burning items will remove the items from a users inventory and destroy them forever. The supply will automatically track the circulating supply of a particular group of items. When items are burnt they the supply will decrease
Crafting is a popular feature used in games to create upgrades. For example burning 2 lvl 2 swords will create a lvl 4 sword.
Passing items in the burn and create function will automically burn items and create new ones.
Burn Items
With the authentication key for the user whose items you would like to burn, use Handcash minter to burn the items by origin
const { HandCashConnect } = require('@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
});
const burnOrderResult = await handCashMinter.burnAndCreateItemsOrder({
burn: {
origins: [origin],
}
});
console.log(burnOrderResult)
Craft Items
Burn items from the user and create an item creation order simultaneously
const { HandCashConnect } = require('@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
});
let items = await handcashAccount.items.getItemsInventory({ searchString: 'Rafa', collectionId, groupingValue: '0df774cab8b1c51d6d74fccd577fe436' });
const itemsToBurn = items.slice(0, 2);
const loadedItemData = await ComponentsFactory.getItemsLoader().loadItems();
// Burn 2 Rafa to Craft 1 Alex
let burnOrderResult = await handCashMinter.burnAndCreateItemsOrder({
burn: {
origins: itemsToBurn.map((item: any) => item.origin),
},
issue: {
items: [itemToCreate],
collectionId: collectionId,
}
});
console.log(burnOrderResult)
Updated about 1 month ago