Mint a Secret NFT
Prerequisites
Minting a Secret NFT on-chain using Ternoa-JS
import fs from "fs";
import {
getKeyringFromSeed,
mintSecretNFT,
File,
TernoaIPFS,
WaitUntil,
} from "ternoa-js";
const main = async () => {
try {
const ipfsClient = new TernoaIPFS(new URL("IPFS_NODE_URL"), "IPFS_API_KEY");
const keyring = await getKeyringFromSeed("//TernoaTestAccount");
const CLUSTER_ID = 0; // The cluster of TEE enclaves used to store private key shares
const SECRET_NFT_ROYALTY = 10; // Percentage of all second sales that the secret NFT creator will receive - 10%.
const COLLECTION_ID = undefined; // The collection to which the secret NFT belongs. Optional Parameter: Default is undefined.
const IS_SOULBOUND = false; // If true, makes the Secret NFT a Soulbound token. The default is false.
const NFTFile = new File(
[await fs.promises.readFile("FILE_NAME")],
"FILE_NAME",
{
type: "FILE_TYPE",
}
);
const secretNFTFile = new File(
[await fs.promises.readFile("SECRET_FILE_NAME")],
"SECRET_FILE_NAME",
{
type: "SECRET_FILE_TYPE",
}
);
const nftMetadata = {
title: "Nice souvenir",
description: "This is my first Secret NFT on Ternoa.",
};
const secretNftMetadata = {
title: "(OPTIONAL) Something strong.",
description: "(OPTIONAL) This description is public.",
};
const secretNftData = await mintSecretNFT(
NFTFile,
nftMetadata,
secretNFTFile,
secretNftMetadata,
ipfsClient,
keyring,
CLUSTER_ID,
SECRET_NFT_ROYALTY,
COLLECTION_ID,
IS_SOULBOUND,
WaitUntil.BlockInclusion
);
console.log("The on-chain Secret NFT id is: ", secretNftData.event.nftId);
} catch (e) {
console.error(e);
}
};Next
Support
Last updated