# tonweb-mnemonic

> Mnemonic code for generating deterministic keys for TON (The Open Network)

Latest version **1.0.1** (published 2022-03-03) · GPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install tonweb-mnemonic
pnpm add tonweb-mnemonic
yarn add tonweb-mnemonic
bun add tonweb-mnemonic
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score; declining downloads.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2022-03-03 |
| First published | 2020-03-02 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=15 |
| Dependencies | 1 |
| Unpacked size | 351.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | tolyayanot, rulon |
| Keywords | BIP39, Blockchain, Mnemonic, TON, The Open Network |

## Links

- npm: https://www.npmjs.com/package/tonweb-mnemonic
- Homepage: https://github.com/toncenter/tonweb-mnemonic#readme
- Issues: https://github.com/toncenter/tonweb-mnemonic/issues
- npm.io page: https://npm.io/package/tonweb-mnemonic

## Dependencies (1)

- [tweetnacl](https://npm.io/package/tweetnacl.md) ^1.0.3

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2022-03-03
- 1.0.0 — 2022-01-08
- 0.0.2 — 2020-03-04
- 0.0.1 — 2020-03-02

## README

# tonweb-mnemonic

[![NPM](https://img.shields.io/npm/v/tonweb-mnemonic.svg)](https://www.npmjs.org/package/tonweb-mnemonic)

Mnemonic code for generating deterministic keys for TON blockchain.


## Features

- library interface is similar to the library `bitcoinjs/bip39`
  (mnemonic for Bitcoin),
- there is only one dependency: `tweetnacl`,
- supports both Browser (UMD) and Node.js (>=15, CommonJS)
- written in TypeScript and provides typing declarations


## Install

`npm install --save tonweb-mnemonic`


## Usage in browser

```html
`<script src="libs/tonweb.js"></script>`
`<script src="libs/tonweb-mnemonic.js"></script>`

<script type="application/javascript">
    // mnemonic is set to window.TonWeb object if it exists:
    const tonMnemonic = window.TonWeb.mnemonic;    
</script>
```


## Usage in Node.js

```js
import tonMnemonic from "tonweb-mnemonic";

async function example() {
    tonMnemonic.wordlists.EN;
    // -> array of all words

    const mnemonic = await tonMnemonic.generateMnemonic();
    // -> ["vintage", "nice", "initial", ... ]  24 words by default

    await tonMnemonic.validateMnemonic(mnemonic);
    // -> true

    await tonMnemonic.isPasswordNeeded(mnemonic);
    // -> false

    await tonMnemonic.mnemonicToSeed(mnemonic);
    // -> Uint8Array(32) [183, 90, 187, 181, .. ]

    const keyPair = await tonMnemonic.mnemonicToKeyPair(mnemonic);
    // -> {publicKey: Uint8Array(32), secretKey: Uint8Array(64)}

    toHexString(keyPair.publicKey);
    // -> "8c8dfc9f9f58badd76151775ff0699bb2498939f669eaef2de16f95a52888c65"

    toHexString(keyPair.secretKey);
    // -> "b75abbb599feed077c8e11cc8cadecfce4945a7869a56d3d38b59cce057a3e0f8c8dfc9f9f58badd76151775ff0699bb2498939f669eaef2de16f95a52888c65"
}

function toHexString(byteArray) {
    return Array.prototype.map.call(byteArray, function(byte) {
        return ('0' + (byte & 0xFF).toString(16)).slice(-2);
    }).join('');
}
```


## Contributing

We will gladly accept any useful contributions.


### TO DO:

- write tests for all functions (improve tests coverage)
- implement tests execution on all OSes in Node
- implement tests execution in Browser (i.e. headless Chrome)


### Development guide

`npm install` — to install dependencies

`npm run build` — to make a *development* build

`npm run build:ci` — to make a *production* build

`npm run test:manual` — to run manual tests in the browser


## Contributors

- [rulon](https://github.com/rulon)
- [tolya-yanot](https://github.com/tolya-yanot)
- [Slava Fomin II](https://github.com/slavafomin)

---
_Source: https://npm.io/package/tonweb-mnemonic · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
