JavaScript implementation for the new CashAddr address format for Bitcoin Cash and SLP.
Compliant with the original CashAddr specification which improves upon BIP 173.
Note: This is a JavaScript implementation of the CashAddr format specification. If you are looking for a general purpose Bitcoin Cash address translation library, check out the easy-to-use and well-tested BchAddr.js.
$ npm install --save cashaddrjs-slp
$ bower install --save cashaddrjs-slp
You may also download the distribution file manually and place it within your third-party scripts directory: dist/cashaddrjs-slp-0.2.12.min.js.
const cashaddr = require('cashaddrjs-slp');
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'
Note: This is a JavaScript implementation of the CashAddr format specification. If you are looking for an easy-to-use and well-tested library to translate between different formats, check out BchAddr.js.
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/simpleledger/cashaddrjs/master/dist/cashaddrjs-slp-0.2.12.min.js"></script>
</head>
...
</html>
$ npm run docs
Browse automatically generated jsdocs online.