Quickstart - Node JS
Last updated
Last updated
This tutorial is designed to guide you through the process of setting up a server-side dApp that enables you to mint, retrieve, and sell an NFT from a NodeJS application. We will achieve this by leveraging the tools provided in our SDK:
Ternoa-JS library: An isomorphic NodeJS that seamlessly integrates custom Ternoa FRAMEs for interacting with the blockchain. Find more information about it .
Ternoa Indexer: A GraphQL Indexer responsible for parsing Ternoa's on-chain data, which can be directly used in your project or accessed via our instance.
Before getting started, please ensure that you have the following prerequisites in place:
with Alphanet CAPS from the
Install and configure your preferred code editor (for this tutorial, we will be using Visual Studio Code [VSC]).
Install , along with NPM.
Generate an IPFS Key from the
The simplest way to quickstart jumping into Ternoa SDK and begin building on the blockchain, is to download the starter repository , and start our tutorial:
We already installed the Ternoa-JS, you can directly run the following command:
In the .env.example
file, you will find the expected environment variables. Copy and paste them into a .env
file at the root of the project.
SEED_TEST_FUNDS
: The Ternoa account seed you will use to sign transactions.
In the src/basics/
folder we will find the following files:
01_mintNFT.ts
: In this 1st step, you will understand how to initialize the API and run your first on-chain transaction to create an NFT. Keep the NFT id from the log with you as you will need it later.
02_getNFT.ts
: In the 2nd step, you will see how to use our Indexer to retrieve your NFT data.
03_sellNFT.ts
: In the 3rd and last step, you will learn how to list your NFT for sale on a marketplace.
Run the following command to execute each script once you have read carefully the comments (replace FILENAME with the correct file name):
Impressive, isn't it? Just one line of code to create an NFT and another single line to list it on a marketplace. Exciting, isn't it? Now, you're all set to kickstart your dApp development journey using our toolkit. Let's get started!
Just follow the advanced guide:
01-mintSecretNFT.ts
: In this 1st advanced step you will see how to create a secret NFT, upload metadata on IPFS, encrypt content, and send some private key shares on a TEE/SGX Cluster.
IPFS_API_KEY
: An IPFS KEY generated with the Ternoa . After being generated, the IPFS key may need a few minutes to become effective for use with the Ternoa client.