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

simple-nano-wallet-js

v0.1.5

Published

**Simple Nano Wallet JS**

Downloads

8

Readme

Simple Nano Wallet JS

Simple nano wallet with in memory key managment.
Made by Nanswap Nodes - Hosted nodes provider

Features

  • Easily send and receive nano with local signature
  • Use your own node or any node provider
  • Auto receive blocks of wallet accounts with websocket
  • Receive all receivable blocks for an account
  • Create wallet from seed or from random entropy
  • Create derived accounts
  • Suppport custom prefix & decimal for custom network such as Banano or DogeNano

Installation
Using npm

npm install simple-nano-wallet-js

Using yarn

yarn add simple-nano-wallet-js

Usage:
Create new wallet

const { Wallet } = require('simple-nano-wallet-js');
const { wallet: walletLib} = require('multi-nano-web')

let seed = walletLib.generateLegacy().seed // save & backup it somewhere!
// initialize wallet
const wallet = new Wallet({
            RPC_URL: 'http://127.0.0.1:7076',
            WORK_URL: 'http://127.0.0.1:7076',
            WS_URL: `ws://127.0.0.1:7078`,
            seed: seed,
            defaultRep: "nano_1banexkcfuieufzxksfrxqf6xy8e57ry1zdtq9yn7jntzhpwu4pg4hajojmq",
        })

// Generate 10 derived accounts
let accounts = wallet.createAccounts(10)
// ["nano_3g5hpb4kwqgakt4cx11ftq6xztx1matfhgkmhunj3sx4f4s3nwb6hfi3nts1", ... ]

Auto Receive
By default, when a websocket is provided, receivable blocks for all wallet accounts will be processed automatically.
To disable this feature, set autoReceive to false when initializing the wallet.

Manually Receive

// receive all receivable blocks for an account
let hashesReceive = await wallet.receiveAll("nano_3g5hpb4kwqgakt4cx11ftq6xztx1matfhgkmhunj3sx4f4s3nwb6hfi3nts1")

Send

// send 0.001 nano from nano_3g5hp... to nano_3g5hp...
let hash = await wallet.send({
        source: "nano_3g5hpb4kwqgakt4cx11ftq6xztx1matfhgkmhunj3sx4f4s3nwb6hfi3nts1", // must be in wallet. 
        destination: "nano_3g5hpb4kwqgakt4cx11ftq6xztx1matfhgkmhunj3sx4f4s3nwb6hfi3nts1",
        amount: wallet.megaToRaw(0.001),
})
        

Custom networks

let headerAuth = { // custom header for authentification
     "nodes-api-key": process.env.NODES_API_KEY
}

// DogeNano Wallet
const walletXDG = new Wallet({
            RPC_URL: 'https://nodes.nanswap.com/XDG',
            WORK_URL: 'https://nodes.nanswap.com/XDG',
            WS_URL: `wss://nodes.nanswap.com/ws/?ticker=XDG&api=${process.env.NODES_API_KEY}`,
            seed: seedXDG,
            defaultRep: "xdg_1e4ecrhmcws6kwiegw8dsbq5jstq7gqj7fspjmgiu11q55s6xnsnp3t9jqxf",
            prefix: 'xdg_',
            decimal: 26,
            customHeaders: headerAuth,
            wsSubAll: false, 
        })
// Banano Wallet
const walletBAN = new Wallet({
            RPC_URL: 'https://nodes.nanswap.com/BAN',
            WORK_URL: 'https://nodes.nanswap.com/BAN',
            WS_URL: `wss://nodes.nanswap.com/ws/?ticker=BAN&api=${process.env.NODES_API_KEY}`,
            seed: seedBAN,
            defaultRep: "ban_1banexkcfuieufzxksfrxqf6xy8e57ry1zdtq9yn7jntzhpwu4pg4hajojmq",
            prefix: 'ban_',
            decimal: 29,
            customHeaders: headerAuth,
            wsSubAll: false
        })

This lib is intended for small project (<5000 accounts), for a more scablable system, it is recommended to use a database to store the accounts keys.