Mint a Secret NFT
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 Secret NFT on-chain using Ternoa-JS
To create an NFT on the Ternoa chain, Ternoa-JS provides you with a mintSecretNFT
helper to do so.
Please note that an api-key is needed to store data on those gateways. Visit IPFS Key Manager to obtain your API Key. After being generated, the key may need a few minutes to become effective for use with the Ternoa client. Learn about the Ternoa IPFS client here.
This program uses the Ternoa-js library to mint a new Secret NFT on the Ternoa blockchain. The program first creates an instance of the TernoaIPFS class that connects to a specified IPFS node using a given API key. This instance allows the user to interact with the IPFS network and store NFT metadata. Then the program retrieves a keyring to sign the on-chain minting transaction. It also sets various options such as the cluster-ID and royalty percentage for the Secret NFT creator. The program then creates a new instance of the File class for both the public file and the secret file with their respective filenames and file types. The program sets the metadata for the NFT and secret NFT and finally calls the mintSecretNFT function with the necessary parameters, which mints the new Secret NFT and returns its ID, printed to the console. If there is an error during the execution of the program, it will be caught by the catch block and logged into the console.
Use your own account by updating the //TernoaTestAccount
with your account seed when retrieving the keyring from the example below.
Here are detailed the mintSecretNFT
helper parameters:
The response returned is an object promise containing:
event
- the Secret NFT creation event (a combination of the NFTCreatedEvent & the SecretAddedToNFTEvent returned by the Ternoa blockchain) with the following data:
clusterResponse
- the response of the TEE cluster which is an array of responses from the enclaves containing objects with the following data:
Next
The next step will be getting the NFT data from the Ternoa Indexer using the NFT id just generated. Keep it and continue on the Secret NFT guide.
Support
If you face any trouble, feel free to reach out to our community engineers in our Discord.
Last updated