# @chris.troutner/bch-js

> Bitcoin Cash JavaScript Library based on BITBOX

Latest version **3.4.1** (published 2020-08-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @chris.troutner/bch-js
pnpm add @chris.troutner/bch-js
yarn add @chris.troutner/bch-js
bun add @chris.troutner/bch-js
```

## Health

**Score 5/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.4.1 |
| Published | 2020-08-05 |
| First published | 2019-07-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 45 |
| Unpacked size | 2.4 MB |
| Known vulnerabilities | 0 (+26 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Chris Troutner |
| Maintainers | chris.troutner |

## Links

- npm: https://www.npmjs.com/package/@chris.troutner/bch-js
- Repository: https://github.com/christroutner/bch-js
- Issues: https://github.com/christroutner/bch-js/issues
- npm.io page: https://npm.io/package/@chris.troutner/bch-js

## Dependencies (45)

- [ini](https://npm.io/package/ini.md) ^1.3.5
- [wif](https://npm.io/package/wif.md) ^2.0.6
- [bigi](https://npm.io/package/bigi.md) ^1.4.2
- [bs58](https://npm.io/package/bs58.md) ^4.0.1
- [axios](https://npm.io/package/axios.md) ^0.19.0
- [bip21](https://npm.io/package/bip21.md) github:Bitcoin-com/bip21
- [bip38](https://npm.io/package/bip38.md) ^2.0.2
- [bip39](https://npm.io/package/bip39.md) ^3.0.2
- [bip66](https://npm.io/package/bip66.md) ^1.1.5
- [chalk](https://npm.io/package/chalk.md) ^2.3.0
- [clear](https://npm.io/package/clear.md) 0.1.0
- [touch](https://npm.io/package/touch.md) ^3.1.0
- [apidoc](https://npm.io/package/apidoc.md) ^0.17.7
- [assert](https://npm.io/package/assert.md) ^2.0.0
- [buffer](https://npm.io/package/buffer.md) ^5.1.0
- [ecurve](https://npm.io/package/ecurve.md) ^1.0.6
- [figlet](https://npm.io/package/figlet.md) ^1.2.0
- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [qrcode](https://npm.io/package/qrcode.md) ^1.4.1
- [cp-file](https://npm.io/package/cp-file.md) ^7.0.0
- [slp-mdm](https://npm.io/package/slp-mdm.md) 0.0.6
- [bc-bip68](https://npm.io/package/bc-bip68.md) ^1.0.5
- [coininfo](https://npm.io/package/coininfo.md) github:Bitcoin-com/coininfo
- [node-cmd](https://npm.io/package/node-cmd.md) ^3.0.0
- [@uppy/tus](https://npm.io/package/@uppy/tus.md) ^1.5.12
- [commander](https://npm.io/package/commander.md) ^3.0.0
- [git-clone](https://npm.io/package/git-clone.md) ^0.1.0
- [socket.io](https://npm.io/package/socket.io.md) ^2.1.1
- [@uppy/core](https://npm.io/package/@uppy/core.md) ^1.10.4
- [cashaddrjs](https://npm.io/package/cashaddrjs.md) ^0.3.3
- [node-emoji](https://npm.io/package/node-emoji.md) ^1.8.1
- [slp-parser](https://npm.io/package/slp-parser.md) 0.0.4
- [bip-schnorr](https://npm.io/package/bip-schnorr.md) ^0.3.0
- [bip32-utils](https://npm.io/package/bip32-utils.md) github:Bitcoin-com/bip32-utils#0.13.1
- [randombytes](https://npm.io/package/randombytes.md) ^2.0.6
- [safe-buffer](https://npm.io/package/safe-buffer.md) ^5.1.2
- [bignumber.js](https://npm.io/package/bignumber.js.md) ^9.0.0
- [repl.history](https://npm.io/package/repl.history.md) ^0.1.4
- [bchaddrjs-slp](https://npm.io/package/bchaddrjs-slp.md) ^0.2.5
- [bitcoincash-ops](https://npm.io/package/bitcoincash-ops.md) github:christroutner/bitcoincash-ops
- [satoshi-bitcoin](https://npm.io/package/satoshi-bitcoin.md) ^1.0.4
- [socket.io-client](https://npm.io/package/socket.io-client.md) ^2.1.1
- [bitcoincashjs-lib](https://npm.io/package/bitcoincashjs-lib.md) github:christroutner/bitcoincashjs-lib#master
- [bitcoinjs-message](https://npm.io/package/bitcoinjs-message.md) ^2.0.0
- [bch-wallet-bridge.js](https://npm.io/package/bch-wallet-bridge.js.md) github:web3bch/bch-wallet-bridge.js#master

## Recent versions

- 3.4.1 (latest) — 2020-08-05
- 3.4.0 — 2020-07-29
- 3.3.5 — 2020-07-19
- 3.3.4 — 2020-07-13
- 3.3.3 — 2020-07-08
- 3.3.2 — 2020-07-02
- 3.3.1 — 2020-06-27
- 3.3.0 — 2020-06-14
- 3.2.1 — 2020-06-12
- 3.2.0 — 2020-06-08
- 3.1.2 — 2020-06-06
- 3.1.1 — 2020-06-06
- 3.1.0 — 2020-06-06
- 3.0.5 — 2020-06-06
- 3.0.4 — 2020-06-05
- … 85 more at https://npm.io/package/@chris.troutner/bch-js/versions

## README

# bch-js

[![Build Status](https://travis-ci.org/christroutner/bch-js.svg?branch=master)](https://travis-ci.org/christroutner/bch-js)
[![Version](https://img.shields.io/npm/v/@chris.troutner/bch-js)](https://www.npmjs.com/package/@chris.troutner/bch-js)
[![Downloads/week](https://img.shields.io/npm/dw/@chris.troutner/bch-js)](https://npmjs.org/package/@chris.troutner/bch-js)
[![License](https://img.shields.io/npm/l/@chris.troutner/bch-js)](https://github.com/christroutner/bch-js/blob/master/LICENSE.md)

**Deprecation Warning:** This repository has been moved to the [Permissionless Software Foundation bch-js repository](https://github.com/Permissionless-Software-Foundation/bch-js). This repository is deprecated. [@chris.troutner/bch-js v3.4.1](https://www.npmjs.com/package/@chris.troutner/bch-js) is the last version published from this repository. [@psf/bch-js v3.5.2+](https://www.npmjs.com/package/@psf/bch-js) is the continuation of the library.



[bch-js](https://www.npmjs.com/package/@chris.troutner/bch-js) is a JavaScript npm library for creating web and mobile apps for interacting with the Bitcoin Cash (BCH) blockchain. It can be used for free, but requires an account on [FullStack.cash](https://fullstack.cash) for increased rate limits. Find out more from [this article](https://troutsblog.com/research/bitcoin-cash/how-to-bch-full-stack-developer).

### Quick Start Videos:
Here are two YouTube walk-through videos to help you get started:
- [Introduction to bch-js and the bch-js-examples repository](https://youtu.be/GD2i1ZUiyrk)
- [Working with the FullStack.cash JWT token](https://youtu.be/GD2i1ZUiyrk)

### Quick Links
- [npm Library](https://www.npmjs.com/package/@chris.troutner/bch-js)
- [Documentation](https://bchjs.fullstack.cash/)
- [Examples](https://github.com/Permissionless-Software-Foundation/bch-js-examples)
- [api.fullstack.cash](https://api.fullstack.cash) - The REST API this library talks to by default.
- [FullStack.cash Account](https://fullstack.cash/login) - Get your API key to unlock increased rate limits.
- [FullStack.cash](https://fullstack.cash) - cloud-based infrastructure for application
developers.
- [Permissionless Software Foundation](https://psfoundation.cash) - The organization that maintains this library.


### Quick Notes

- Install library: `npm install @chris.troutner/bch-js`

- Instantiate the library in your code:
```
const BCHJS = require("@chris.troutner/bch-js")
let bchjs = new BCHJS()

// testnet
bchjs = new BCHJS({ restURL: 'https://tapi.fullstack.cash/v3/' })
```

This is a fork of the [BITBOX SDK](https://github.com/Bitcoin-com/bitbox-sdk) (which is maintained by Bitcoin.com). This library is intended to be paired with
the [bch-api](https://github.com/christroutner/bch-api) REST API.

If you need a backward-compatible instance of this library, you can use a
'shim'. Do it like this:
```
const BCHJS = require("@chris.troutner/bch-js")
const bitbox = BCHJS.BitboxShim({ restURL: 'https://api.fullstack.cash/v3/' })
```

### API Key
The [bch-api](https://github.com/christroutner/bch-api) REST API hosted by [FullStack.cash](https://fullstack.cash) uses JWT tokens to pay for increased
rate limits when interacting with the back end server. See [this article](https://troutsblog.com/research/bitcoin-cash/how-to-bch-full-stack-developer) if you want to understand the system-as-a-whole. The JWT token can be fed to bch-js *implicitly* or *explicitly*.

- Implicitly: bch-js will detect your JWT token by setting the `BCHJSTOKEN` environment variable.
- Explicitly: You can directly feed in the JWT token with the `apiToken` property when instantiating the library. Here is an example:

```
const BCHJS = require("@chris.troutner/bch-js")
let bchjs = new BCHJS({
  restURL: 'https://api.fullstack.cash/v3/',
  apiToken: 'eyJhbGciO...' // Your JWT token here.
})
```

### Gatsby
bch-js is included in this [gatsby-ipfs-template](https://github.com/Permissionless-Software-Foundation/gatsby-ipfs-template) for building uncensorable web apps that can interact with the blockchain. When building a Gatsby (or other front-end app that uses Webpack), you'll need to add these lines to your `gatsby-node.js` file, as per [this issue](https://github.com/gatsbyjs/gatsby/issues/564):
```
exports.onCreateWebpackConfig = ({ actions }) => {
  actions.setWebpackConfig({
    node: {
      fs: 'empty'
    }
  })
}
```

This is because the new IPFS class in bch-js uses the fs library for uploading files, which is not supported by Gatsby.

## Features
This library sets itself apart from BITBOX with the following features:

- [ECMAScript 2017 standard JavaScript](https://en.wikipedia.org/wiki/ECMAScript#8th_Edition_-_ECMAScript_2017) used instead of TypeScript. Works
natively with node.js v10 or higher.

- Full SLP tokens support: bch-js has full support for all SLP token functionality, including send, mint, and genesis transactions. It also fully support all aspects of [non-fugible tokans (NFTs)](https://www.youtube.com/watch?v=vvlpYUx6HRs).

- [Semantic Release](https://github.com/semantic-release/semantic-release) for
continuous delivery using semantic versioning.

- [Greenkeeper](https://greenkeeper.io/) automatic dependency management for
automatically maintaining the latest, most secure dependencies.

- [IPFS uploads](https://ipfs.io) of all files and dependencies, to backup
dependencies in case they are ever inaccessible from GitHub or npm.



## Documentation:

Full documentation for this library can be found here:
- [Documentation](https://bchjs.fullstack.cash/)

Original documentation on BITBOX is available at:

- [General docs](https://developer.bitcoin.com)
- [BITBOX Introduction](https://developer.bitcoin.com/bitbox)
- [BITBOX API Reference](https://developer.bitcoin.com/bitbox/docs/getting-started)


bch-js uses [APIDOC](http://apidocjs.com/) so that documentation and working code
live in the same repository. To generate the documentation:
- `npm run docs`
- Open the generated `docs/index.html` file in a web browser.

## Support
Have questions? Need help? Join our community support
[Telegram channel](https://t.me/bch_js_toolkit)

## IPFS Releases

I will periodically publish IPFS releases of this repository, including all
dependencies in the `node_modules` folder. This ensures working copies of this
repository can be retrieved in case there is any drift in dependency files, or
if dependencies are pulled from npm or GitHub.

- Initial fork on 5/9/2019:
  - without node_modules folder: QmQFHfbBQdEHfhtiRLbXtX1NcgnfL45hZb7TbQimTXAuzG (4 MB)
  - with node_modules folder: QmXq9Ds6Qdkg9xbRhcF8pay9KabA6QN2y7bx3wvSqiXifk (107 MB)

- v1.0.0 - refactored to pure JavaScript:
  - without node_modules folder: QmNjFsiTZRMAUa9rZpXqZqivv9JLaNicwLSPHjyLB7PVDk (1 MB)
  - with node_modules folder: Qma9ScApwBtuL7dpdSk7jpBFTxbqRdiR921WjyP75SU7bT (100 MB)

## License
[MIT](LICENSE.md)

---
_Source: https://npm.io/package/@chris.troutner/bch-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
