addCategories
This function allow admin user to add categories to a compatible Bcode contract. The add categories functionality support max 5 new categories per time.
To be able to handle NodeJS file the format will be blob.
The function is fully typed.
Params
Param | Description |
---|---|
nfts | Array of Nft objects |
contractId | Contract identifier can be found on online platform |
Attributes field is not mandatory but can have this form
Param | Description | Mandatory |
---|---|---|
trait_type | Shown name of teh attribute | Yes |
type | Attribute type supported by the platform | Yes |
value | Attribute's value | Yes |
private | Privatness of the attribute, it will or not end on blockchain | No |
link | Extra url for attribute | No |
file | Object referring a attribute's file | No |
For type details follow the type declaration.
Usage
import { BcodeSDK } from "@bcode-tech/bcode-sdk";
const CONTRACT_ID = "ContractID";
const loadData = () => {
const nftImage = fs.readFileSync("./nft-image.png");
const attributeImage = fs.readFileSync("./attribute-image.png");
const nftImageBlob = new Blob([nftImage], { type: "image/png" });
const attributeImageBlob = new Blob([nftImage], { type: "image/png" });
const nfts = [
{
name: "Token name",
description: "Token description",
isUnlimited: false,
quantity: 1,
external_url: "https://your-site.com",
image: {blob, name: "nft-image.png},
attributes: [
{
trait_type: "New attribute",
type: "image",
value: "",
file: {blob, name: "attribute-image.png" },
},
],
},
];
return nfts;
};
const fun = () => {
const sdk = BcodeSDK.create({
email: "your@email.com",
password: "your-secure-password",
config: {env: 'DEV', debugMode: true},
version: "v1",
});
await sdk.init()
const nfts = loadData();
const requestId = await sdk.addCategories({
nfts,
contractId: CONTRACT_ID,
});
};