Access your account through a seed & a keyring

Prerequisites

Before getting started, please ensure that you have the following prerequisites in place:

  1. Create a Ternoa account with Alphanet CAPS from the faucet.

  2. Install and configure your preferred code editor (for this tutorial, we will be using Visual Studio Code [VSC]).

  3. Install NodeJS v.14+, along with NPM.

If you are not familiar with the process of creating a transaction on the Ternoa chain, we highly suggest first reading the Getting Started section of the documentation with a focus on the Ternoa-js workflow and the two transaction approaches.

Most of our examples in this documentation use the automated approach and involve creating the Keyring to sign and submit a transaction.

Polkadot Keyring's definition: The Keyring allows you to manage a set of keys in a consistent environment, allows you to perform operations on these keys (such as sign/verify), and never exposes the secretKey to the outside world. Learn more on keyring in the Polkadot's documentation.

Generating a keyring

We assume you have already created a new wallet for development purposes with no CAPS on Ternoa Mainnet. You must use a development wallet with NO REAL MONEY in it when learning, practicing, and testing. The 12 worlds' seeds must be stored in a .env.variable file. Be sure to NEVER make your seed publicly accessible or visible in a browser.

import { initializeApi, getKeyringFromSeed } from "ternoa-js";

const main = async () => { 
	try { 
		await initializeApi();	
		const ACCOUNT_SEED = "REPLACE_WITH_YOUR_SEED"; // 12 worlds seed
		const keyring = await getKeyringFromSeed(ACCOUNT_SEED);
		console.log(`The keyring address is ${keyring.address}`);
		process.exit(0)
	} catch (e) {
		console.error(e);
		process.exit(1)
	} finally {
		process.exit(0)
	}
};
main();

You can now provide your keyring as function parameters to create some transactions like we do to mint an NFT. See more examples in the NFT features & Pallets section.

Last updated