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

bandprotocol

v0.5.11

Published

Javascript client for Band Protocol blockchain

Downloads

33

Readme

Code Style: prettier TypeScript MIT Licence Dependency Status devDependency Status

The library allows Web, Node.js and React Native environment to connect with Band Chain. The code itself is written in TypeScript, but deployed as older ES5 ia Browserify to support older browser and React Native environments.

Dependencies

Installation

NPM

npm i --save bandprotocol

Basic Usage

import BandProtocolClient from 'bandprotocol'
import { secretKey } from './config'

const client = new BandProtocolClient({
  httpEndpoint: 'http://localhost:26657',
  keyProvider: secretKey,
})

Key Generation

This library supports secure key generations using ED25519 algorithm.

const {
  mnemonic, // Array<string x 12> of Mnemonic phrase
  secretKey, // 64-byte hex string secret key
  verifyKey, // 32-byte hex string public key
  address, // IBAN-style address
} = BandProtocolClient.generateRandomKey()

Transaction Generation

Every transaction is created on the remote node via JSON-RPC protocol and signed on the client. This design allows higher portability comparing to client-generated transactions, while the client keeps its secret keys secured.

See BandProtocol's Gitbook for documentation on transaction formats.

import BandProtocolClient from 'bandprotocol'

// Initialize client
const client = new BandProtocolClient({
  httpEndpoint: 'http://localhost:26657',
  keyProvider: '<secretKey>',
})

// Generate unsigned transaction from node
const unsignedTx = await client.blockchain.txgen({
  msgid: 1,
  vk: '6ddb22994b551f4da5818e7a257d467e9af753348194f31dddc5f9aa489d3da1',
  dest: 'AX62 ECTZ WZZ5 XVTG N8NL 6EVB 9TPH TELJ ZBRL',
  token: 'BX63 AAAA AAAA AAAA AAAA AAAA AAAA AAAA AAAA',
  value: '200000',
})

// Sign the transaction
const signedTx = client.key.sign(unsignedTx)

// Broadcast the signed transaction
const result = await client.blockchain.broadcastTxn(signedTx)

Encrypted Secret Key (SecretBox)

The client supports secret key encryption via Libsodium's Secret-key encryption. Application server can store the secretbox without exposing the risk of leaking user's secret keys, given that the passcodes are strong enough.

To create secretbox from secret key, you'll need to initialize the client with secret key:

const passcode = '<some_user_defined_passcode>'
const client = new BandProtocolClient({ keyProvider: '<secretKey>' })

const secretbox = client.encrypt(passcode)

To restore client instance and secret key:

const client = new BandProtocolClient({
  keyProvider: {
    secretbox: '<encrypted_secretbox>',
    passcode: '<user_passcode>',
  },
})

const secretKey = client.getSecretKey()

Development

Make sure you have Node.js v8+ installed. Then run:

yarn install

Test

Only Unit Tests are implemented for now. Integration tests with testnet can be possible, and we highly encourage you to contribute to make this happen.

yarn test

Build

To make it compatible with React Native, the TypeScript code is compiled and shimmed to avoid direct call of Node.js libraries. compile.js takes care of compilation process using Browserify.

yarn build

License

MIT