Skip to content

Latest commit

 

History

History
83 lines (58 loc) · 1.59 KB

EXAMPLES.md

File metadata and controls

83 lines (58 loc) · 1.59 KB

Examples

Create Mnemonic Object

Defaults to Bitcoin mainnet with English words.

const code = new Mnemonic();

Get string phrase from Mnemonic Object

const code = new Mnemonic();
code.toString();

// Example output: job shop small once merit ethics enhance direct lobster else copper cotton

Set network as mainnet

import { ltc } from '@hyperbitjs/chains';

const code = new Mnemonic({ network: ltc.mainnet });
code.toString();

Check if Mnemonic Object is valid in Spanish

const code = new Mnemonic({ language: 'spanish' });
const isValid = Mnemonic.isValid(code.toString());

Generate a seed based on the code and optional passphrase.

const passphrase = '';
const code = new Mnemonic({ passphrase });

const seedBuffer = code.toSeed();

Get current HD Private Key

const code = new Mnemonic();
const hdPrivateKey1 = code.getHDPrivateKey();

Get word list in English

const words = Mnemonic.words('english');

Get seed without using Mnemonic class

const phrase = Mnemonic.generateMnemonic('english');

Generate Addresses

const code = new Mnemonic();
const addresses = code.generateAddresses();
// Example output: [{ external: {...}, change: {...} }]

console.log(code.accounts);
// Example output: { 0: {}, 1: {} }

console.log(code.accounts['0']);
// Example output: { external: {...}, change: {...} }

console.log(code.accounts['0'].external.get(1));
// Example output:
// privateKey: '';
// address: '';
// path: '';
// wif: '';