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

@cennznet/wallet

v1.2.1

Published

wallet implementation to use with cennznet

Downloads

74

Readme

cennznet-wallet

a wallet and a payload signer for cennznet

Usage

Create a Wallet with HD-Keyring

const {Wallet} = require('@cennznet/wallet');

const wallet = new Wallet();
await wallet.createNewVault('a passphrase');
//By default it comes with a HD Keyring

Backup your wallet

const backup = await wallet.export('a passphrase');
// [{mnemonic, numberOfAccounts,hdPath}]

Reload your wallet

vault = wallet.vault;
wallet2 = new Wallet({vault});
//add keyringTypes: [HDKeyring, SimpleKeyring] if SimpleKeyring is used
await wallet2.unlock(<same passphrase>)

Restore wallet and reset password

mnemonic='ready whisper vapor penalty load gesture elite brick select light caution clever';
hdKeyring=new HDKeyring({mnemonic});
wallet = new Wallet();
wallet.createNewVaultAndRestore('newpass', [hdKeyring]);

Backup an account

const json = await wallet.exportAccount(address, passphrase);

Import single account

const TEST_ACCOUNT = {
    seed: '0x3cf2ec6ffd26587529ab06c82ba9b33110198085f5c6b8d882653d056bf9e0d3',
    address: '5DHzypfuQH7FPhCsrqMxpxkBaPHe8QNhc5s1PwEMDc5p5Nb7',
    publicKey: '0x366010e706af618a6037731b07663d4b6f10eac201c7fdd5fb0bd4727742524d',
    mnemonic: 'insane push cradle toilet token gate chair trim spare blush rebuild top',
};
const keyring = new SimpleKeyring();
await keyring.addPair(alice);
//or
keyring.addFromSeed(hexToU8a(TEST_ACCOUNT.seed));
//or
keyring.addFromMnemonic(TEST_ACCOUNT.mnemonic);
await wallet.addKeyring(keyring);

lock/unlock

await wallet.lock();
// methods marked as @requireUnlocked such as sign, addAccount and etc will fail
await wallet.unlock(passphrase);

generate random account via the default keyring

const address = await wallet.addAccount();

assigned as @cennznet/api's payload signer

api.setSigner(wallet);

check API Document for more details.