Options
All
  • Public
  • Public/Protected
  • All
Menu

ternoa-js

⚙️ Ternoa SDK

npm version

The easiest and fastest way to build on top of Ternoa Chain.

Installation

Node.js

npm install ternoa-js

This package provides TypeScript types, but you will need TypeScript version 4.2 or higher to use them properly.

Quick Start

Functions are organized by theme. In the exemple 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)
})

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 in ternoa-js/blockchain.

Documentation

The official SDK documentation is available: ternoa-js sdk documentation. Additional resources are available on the ternoa official documentation.

SDK Development

Building

To build a new version of the library, run:

npm run build

Generating Documentation

To generate the documentation website, run:

npm run docs

The static website will be located in the docs/ directory.

Testing

The test suites relies on testing pairs located in the testingPairs.ts file. In order to prepare those pairs, the two scripts test-setup.ts and test-teardown.ts respectively fulfilled and emptied them with CAPS. Environment variables SEED_TEST_FUNDS and SEED_TEST_FUNDS_PUBLIC_KEY have to be define to run the test suites.

To run the test suites, run:

npm run test

Code Style

This project uses recommended ESLint and Typescript rules to ensure coding good practices.

We've setup linters and formatters to help catch errors and improve the development experience:

  • Prettier – ensures that code is formatted in a readable way.
  • ESLint — checks code for antipatterns as well as formatting.

Husky proceeds some checks before pushing a new commit. It ensures that: the project is building, there are no linter/formatting issues and the test suites are not broken.

If you use Visual Studio Code editor we suggest you to install ESLint and Prettier extensions.

License

ternoa-js uses an Apache-2.0 License.

Generated using TypeDoc