Mint a Collection
Prerequisites
Before getting started, make sure you have the following ready:
Create a Ternoa account with Alphanet CAPS
Install and set up your editor of choice (we will use Visual Studio Code [VSC] in this tutorial)
Install NodeJS v.14+ & NPM
Minting a Collection on-chain using Ternoa-JS
To create a Collection on the Ternoa chain, Ternoa-JS provides you with a createCollection helper to do so. It returns an object promise containing the CollectionCreatedEvent returned by the Ternoa blockchain.
Replace IPFS_CID in the following code snippet with your CID hash previously generated in "How to prepare Collection assets":
import {
createCollection,
initializeApi,
getKeyringFromSeed,
WaitUntil,
} from "ternoa-js";
const main = async () => {
try {
const keyring = await getKeyringFromSeed("//TernoaTestAccount");
const collectionData = await createCollection(
"IPFS_CID",
undefined,
keyring,
WaitUntil.BlockInclusion
);
console.log(
"The on-chain Collection id is: ",
collectionData.collectionId
);
} catch (e) {
console.error(e);
}
};Here are detailed the createCollection helper parameters:
The response returned includes all the information below according to the parameters provided when creating the Collection.
Next
The next step will be getting the Collection data from the Ternoa Indexer using the Collection id just generated. Keep it and continue on the Retrieve a collection guide.
Support
If you face any trouble, feel free to reach out to our community engineers in our Discord.
Last updated