npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

minterjs-wallet

v6.2.0

Published

Utilities for handling Minter keys

Downloads

148

Readme

Minter JS Wallet

NPM Package Build Status Coverage Status License: MIT

A lightweight Minter Wallet implementation. Forked from ethereumjs-wallet

It is complemented by the following packages:

Motivations are:

  • be lightweight
  • work in a browser
  • support BIP39 mnemonic phrases
  • support BIP32 HD keys

Features not supported:

  • signing transactions
  • managing storage (neither in node.js or the browser)
  • conversion between various wallet formats

Install

npm install minterjs-wallet

or from browser

<script src="https://unpkg.com/minterjs-wallet"></script>
<script>
const wallet = minterWallet.generateWallet();
const wallet2 = minterWallet.walletFromMnemonic('...');
// use async for better performance
const wallet3 = await minterWallet.walletFromMnemonicAsync('...');
</script>

Wallet API

Construction methods:

Mnemonic wallets are generated by a BIP-0044 path, Ethereum path is used by default "m/44'/60'/0'/0/0"

generateWallet(path)

Generates wallet from a random BIP39 mnemonic phrase (uses bip39.generateMnemonic() under the hood).

import {generateWallet} from 'minterjs-wallet';
const wallet = generateWallet();

walletFromMnemonic(mnemonic, path)

Create a wallet instance based on BIP39 12 words mnemonic phrase

import {walletFromMnemonic} from 'minterjs-wallet';
const wallet = walletFromMnemonic('surround tape away million into program organ tonight write prefer inform cool');

walletFromMnemonicAsync(mnemonic, path)

Same as walletFromMnemonic but async and has better performance in browser, because it uses window.crypto.subtle under hood

import {walletFromMnemonicAsync} from 'minterjs-wallet';
const wallet = await walletFromMnemonicAsync('surround tape away million into program organ tonight write prefer inform cool');

walletFromPrivateKey(privateKey)

Create a wallet instance based on a raw private key

import {walletFromPrivateKey} from 'minterjs-wallet';
const privateKeyBuffer = Buffer.from('ef2af2385681c490bc473c2f7e6097fc1a38e6f67b44b81a3350a6583aadd144', 'hex')
const wallet = walletFromPrivateKey(privateKeyBuffer);

Wallet instance methods:

.getAddress()

Return the address: 20 bytes length Buffer or Uint8Array

wallet.getAddress();
// [88,108,62,182,16,84,7,36,101,31,244,29,32,158,20,41,238,62,68,154]

.getAddressString()

Return the Minter-style address

wallet.getAddress();
// 'Mx586c3eb610540724651ff41d209e1429ee3e449a'

.getMnemonic()

Return the mnemonic phrase: 12 words string. Note: Only works with instance created/generated from mnemonic, otherwise it will throw an error.

wallet.getMnemonic();
// 'surround tape away million into program organ tonight write prefer inform cool'

.getPrivateKey()

Return the private key: 32 bytes length Buffer or Uint8Array

wallet.getPrivateKey();
// [239,42,242,56,86,129,196,144,188,71,60,47,126,96,151,252,26,56,230,246,123,68,184,26,51,80,166,88,58,173,209,68]

.getPrivateKeyString()

Return the private key string of 64 hex characters

wallet.getPrivateKeyString();
// 'ef2af2385681c490bc473c2f7e6097fc1a38e6f67b44b81a3350a6583aadd144'

.getPublicKey()

Return the uncompressed Ethereum-style public key: 64 bytes length Buffer or Uint8Array

wallet.getPublicKey();
// [251,82,201,189,133,251,174,27,6,6,18,34,12,222,116,254,99,169,65,249,135,81,170,13,35,99,50,6,231,95,48,69,41,47,96,75,240,242,9,77,23,168,173,59,137,223,128,80,144,69,34,91,145,21,255,133,112,189,68,8,42,245,210,116]

.getPublicKeyString()

Return the Minter-style public key string

wallet.getPublicKeyString();
// 'Mpfb52c9bd85fbae1b060612220cde74fe63a941f98751aa0d23633206e75f3045'

Mnemonic

generateMnemonic()

Generate random 12 words mnemonic phrase. Exposed bip39.generateMnemonic().

import {generateMnemonic} from 'minterjs-wallet';
const mnemonic = generateMnemonic();
// 'surround tape away million into program organ tonight write prefer inform cool'

isValidMnemonic(mnemonic)

Check that given mnemonic is valid, returns boolean, uses bip39.validateMnemonic() under the hood.

import {isValidMnemonic} from 'minterjs-wallet';
const isValid = isValidMnemonic('surround tape away million into program organ tonight write prefer inform cool');
// true

License

MIT License