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.

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

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