0.4.0 ā€¢ Published 3 years ago

eosio-mnemonic v0.4.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Generate EOSIO Mnemonics and associated public/private keys

Install

npm install eosio-mnemonic

Usage

import { Mnemonic } from 'eosio-mnemonic'

/**
 * mnemonic.phrase: e.g. 'reflect note upgrade mention marine sword track pride robust vessel tube sausage kind trick neglect'
 */
const mnemonic = new Mnemonic()

/**
 * Keys
 *  - publicKey: e.g. PUB_K1_71ESPbpkYsR9iQd1tgqxqZqUJFX8veJGUS5RnGGekq4Vb1ExPj
 *  - privateKey: e.g. PVT_K1_du8FBHSYpapVw17ZmWBU3u3dBCARMFe54X49yfPrFCUoXpADk
 */
const { publicKey, privateKey } = mnemonic.keyPairAtIndex(0)

/**
 * Legacy Keys
 *  - publicKeyLegacy: e.g. EOS71ESPbpkYsR9iQd1tgqxqZqUJFX8veJGUS5RnGGekq4Vd64yg6
 *  - privateKeyLegacy: e.g. 5JTBhvdNX1Pa5WKH9mDQGWo2GE17NZDLMt8JHL2Qdj6qeTjzqE6
 */
const { publicKey: publicKeyLegacy, privateKey: privateKeyLegacy } = mnemonic.keyPairAtIndex(0, true)

Options

const mnemonic = new Mnemonic({
  phrase, // Existing phrase, leave undefined to create new one
  passphrase, // Existing mnemonic password, leave undefined to not specify
  numWords // How long you want the mnemonic phrase to be
})

const newFormat = mnemonic.keyPairAtIndex(0) // PUB_K1_ and PVT_K1_
const oldFormat = mnemonic.keyPairAtIndex(0, true) // EOSXXX and 5XXXX

Run tests

npm run test

Author

šŸ‘¤ Syed Jafri

Show your support

Give a ā­ļø if this project helped you!