Accounts

Creation

You can create a new account with a random seed with keypair (ed25519):

import LTO from '@ltonetwork/lto';

const lto = new LTO('T');
const account = lto.account();

console.log(account.seed);  // lion devote brush lemon salmon eyebrow near autumn aspect april ugly position dismiss suit finger
console.log(account.publicKey);  // AvWa7XokpR284pNCnoKZhudQdNA5AV3PXPi6HhggAhbT
console.log(account.privateKey);  // 4dXzhzRcpiukcRBUGfre8s8aRaUqwyKHUzfbQTtNRRMFxZXQ6BsbfKPbA2QVBELNjoxxy6NQkii6HVg1zPzti4mB

It's also possible to recover a keypair from an existing seed:

import LTO from '@ltonetwork/lto';

const lto = new LTO('T');
const seed = 'satisfy sustain shiver skill betray mother appear pupil coconut weasel firm top puzzle monkey seek';
const account = lto.account({ seed });

Nonce

You can create multiple accounts from a single seed phrase, by passing a nonce.

Alternatively, pass a binary value as a nonce. Use the Binary class to convert a string to a binary value

Child accounts

Instead of specifying the seed, you can specify a parent account and a nonce to create a child account. Transactions signed by the child account will be co-signed by the parent so that the parent account will pay the transaction fee.

Multi-chain accounts

LTO Networks supports 3 ciphers: ed25519, secp256k1, and secp256r1. To create an Ethereum-compatible key pair, use the secp256k1 key type and the Ethereum derivation path

For secp256k1, the seed phrase is generated according to bip32 with a length of 12 words. When creating the account from seed, also pass the derivation path.

Seed encryption

It's recommended to encrypt your seed when storing the account

Supply the password to create the account from an encrypted seed

Last updated