Ternoa Wiki
LearnBuildMaintain
  • Learn
    • Getting Started
      • Ternoa Blockchain
      • Building on Ternoa
    • Ternoa Wallet
      • Download
      • Create your Wallet
      • NFT
        • Create NFT
        • Send NFT
      • Account
        • Wallet Address
        • Change Password
        • Mnemonic Key
        • Contact
      • Nova Wallet
    • Ternoa Bridge
      • Get Started - Mainnet
        • Using the Bridge
        • ERC20 CAPS <-> Native CAPS
        • ERC20 CAPS <-> BEP20 CAPS
      • Get Started - Alphanet
        • ETH <-> CAPS
    • Asset Management
      • CAPS
        • Buy CAPS
        • Send/Receive CAPS
        • Claim Test CAPS
    • Staking
      • How to stake on Ternoa
    • Glossary
  • Build
    • Introduction
      • Alphanet
      • Mainnet
    • SDK Javascript
      • Installation
      • Quickstart
      • Reference
  • Maintain
    • How to run a validator on Ternoa
    • Requirements
    • Install Ternoa
  • General
    • Ambassador Program
    • Accelerator Program
    • Community
  • Resources
    • 🔍Ternoa Explorer
    • 📡Ternoa network status
Powered by GitBook
On this page

Was this helpful?

  1. Build
  2. SDK Javascript

Quickstart

An API instance must be initialize using the initializeApi function in ternoa-js/blockchain before calling some SDK functions. The default chain endpoint is:

DEFAULT_CHAIN_ENDPOINT = "wss://alphanet.ternoa.com".

It can be modified by passing a new endpoint as a parameter to the initializeApi function.

Functions are organized by theme. In the example below, the import of generateSeed and getKeyringFromSeed from the subpath ternoa-js/account allows us to generate a new account and display its address.

import { generateSeed, getKeyringFromSeed } from "ternoa-js/account";

(async () => {
  const account = await generateSeed()
  const keyring = await getKeyringFromSeed(account.seed)
  const address = keyring.address
  console.log("Your fresh public address is: ", address)
})().catch((e) => {
  console.log(e)
})

Among all the features provided by the Ternoa SDK, this short snippet of code allows you to create an NFT, submit and sign it at a glance.

This single line createNft function, require a few parameters :

  • some offchainData metadatas,

  • a royalty,

  • a collectionId

if you want this NFT to belong to a collection, a boolean to define its isSoulbound status, the keyring to sign and submit the transaction, and a waitUntil callback parameter, to define at which point we want to get the results of the transaction execution.

import { createNft } from "ternoa-js/nft"
import { generateSeed, getKeyringFromSeed } from "ternoa-js/account"

const createMyFirstNFT = async () => {
  try {
    // We initialize an API instance connected to the Alphanet chain
    await initializeApi()

    // Here we create, sign and submit the NFT transaction with your keyring
    await createNft("My first NFT", 10, undefined, false, keyring, WaitUntil.BlockInclusion)
  } catch (e) {
    console.log(e)
  }
}
PreviousInstallationNextHow to run a validator on Ternoa

Last updated 2 years ago

Was this helpful?