JSPM

  • Created
  • Published
  • Downloads 96004
  • Score
    100M100P100Q152371F
  • License MIT

Bitcoin Cash cashaddr address format support for Node.js and web browsers.

Package Exports

  • cashaddrjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cashaddrjs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

CashAddr.js: The new Bitcoin Cash address format for Node.js and web browsers.

Build Status Coverage Status

NPM

JavaScript implementation for the new CashAddr address format for Bitcoin Cash.

Compliant with the original CashAddr specification which improves upon BIP 173.

You can try out a general purpose Bitcoin Cash address translator using CashAddr.js here.

Installation

Using NPM

$ npm install --save cashaddrjs

Using Bower

$ bower install --save cashaddrjs

Manually

You may also download the distribution file manually and place it within your third-party scripts directory: dist/cashaddrjs-0.2.6.min.js.

Usage

In Node.js

const cashaddr = require('cashaddrjs');
const address = 'bitcoincash:qpm2qsznhks23z7629mms6s4cwef74vcwvy22gdx6a';
const { prefix, type, hash } = cashaddr.decode(address);
console.log(prefix); // 'bitcoincash'
console.log(type); // 'P2PKH'
console.log(hash); // Uint8Array [ 118, 160, ..., 115 ]
console.log(cashaddr.encode(prefix, type, hash)); // 'bitcoincash:qpm2qsznhks23z7629mms6s4cwef74vcwvy22gdx6a'

Browser

Script Tag

You may include a script tag in your HTML and the cashaddr module will be defined globally on subsequent scripts.

<html>
  <head>
    ...
    <script src="https://cdn.rawgit.com/bitcoincashjs/cashaddrjs/master/dist/cashaddrjs-0.2.6.min.js"></script>
  </head>
  ...
</html>

Documentation

Generate and Browse Locally

$ npm run docs

Online

Browse automatically generated jsdocs online.