Decrypt 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
Decrypting a Secret NFT using Ternoa-JS
To decrypt a Secret NFT from the Ternoa chain, Ternoa-JS provides you with a viewSecretNFT
helper to do so. It returns a string promise containing the decrypted base 64 file.
The program starts defining some required variables such as SEED, IPFS_NODE_URL, IPFS_API_KEY, CLUSTER_ID, and NFT_ID. It then creates a new instance of TernoaIPFS
using the IPFS node's URL and API key. It then uses getKeyringFromSeed
function to retrieve the keyring from a provided seed phrase and finally calls the viewSecretNFT
function to decrypt a Secret NFT with the given ID using the keyring, IPFS client, and cluster-ID. The decrypted base64 format of the Secret NFT is then logged to the console. If there is any error during the execution, it will be logged into the console as well.
Use your own account by updating the //TernoaTestAccount
with your account seed when retrieving the keyring from the example below.
Here are detailed the viewSecretNFT
helper parameters:
The response returned a decrypted base64 format of the Secret NFT.
Support
If you face any trouble, feel free to reach out to our community engineers in our Discord.
Last updated