Files
bch-js/README.md
T

123 lines
6.4 KiB
Markdown
Raw Normal View History

2020-07-27 21:32:51 -07:00
# bch-js
2020-11-08 17:46:40 -08:00
[![Version](https://img.shields.io/npm/v/@psf/bch-js)](https://www.npmjs.com/package/@psf/bch-js)
[![Downloads/week](https://img.shields.io/npm/dw/@psf/bch-js)](https://npmjs.org/package/@psf/bch-js)
[![License](https://img.shields.io/npm/l/@psf/bch-js)](https://github.com/Permissionless-Software-Foundation/bch-js/blob/master/LICENSE.md)
2022-04-05 12:10:09 +00:00
[![js-standard-style](https://img.shields.io/badge/javascript-standard%20code%20style-green.svg?style=flat-square)](https://github.com/feross/standard) [![Join the chat at https://gitter.im/Permissionless-Software-Foundation/bch-js](https://badges.gitter.im/Permissionless-Software-Foundation/bch-js.svg)](https://gitter.im/Permissionless-Software-Foundation/bch-js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
2020-07-27 21:32:51 -07:00
[bch-js](https://www.npmjs.com/package/@psf/bch-js) is a JavaScript npm library for creating web and mobile apps that can interact with the Bitcoin Cash (BCH) and eCash (XEC) blockchains. bch-js contains a toolbox of handy tools, and an easy API for talking with [psf-bch-api REST API](https://github.com/Permissionless-Software-Foundation/psf-bch-api). [FullStack.cash](https://fullstack.cash) offers paid cloud access to psf-bch-api. You can run your own infrastructure by following documentation on [CashStack.info](https://cashstack.info).
2020-07-27 21:32:51 -07:00
### Quick Start Videos:
2020-11-08 18:56:48 -08:00
2020-07-27 21:32:51 -07:00
Here are two YouTube walk-through videos to help you get started:
2020-11-08 18:56:48 -08:00
2020-07-27 21:32:51 -07:00
- [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
2020-11-08 18:56:48 -08:00
2020-11-08 17:46:40 -08:00
- [npm Library](https://www.npmjs.com/package/@psf/bch-js)
2020-07-27 21:32:51 -07:00
- [Documentation](https://bchjs.fullstack.cash/)
- [Examples](https://github.com/Permissionless-Software-Foundation/bch-js-examples)
2020-11-08 19:02:30 -08:00
- [bchn.fullstack.cash](https://bchn.fullstack.cash) - The REST API this library talks to by default.
- [FullStack.cash](https://fullstack.cash) - cloud-based infrastructure for application developers.
2020-07-27 21:32:51 -07:00
- [FullStack.cash Account](https://fullstack.cash/login) - Get your API key to unlock increased rate limits.
- [Permissionless Software Foundation](https://psfoundation.cash) - The organization that maintains this library.
2022-04-30 16:04:22 -07:00
- [CashStack.info](https://cashstack.info) - bch-js is part of the Cash Stack, a JavaScript framework for writing web 2 and web 3 business applications.
2020-07-27 21:32:51 -07:00
### Quick Notes
2020-11-08 17:46:40 -08:00
- Install library: `npm install @psf/bch-js`
2020-07-27 21:32:51 -07:00
- Instantiate the library in your code:
2020-11-08 18:56:48 -08:00
```javascript
import BCHJS from "@psf/bch-js"
2020-11-08 19:02:30 -08:00
let bchjs = new BCHJS() // Defaults to BCHN network.
2020-07-27 21:32:51 -07:00
```
2020-11-08 18:49:45 -08:00
This library is intended to be paired with
the [psf-bch-api](https://github.com/Permissionless-Software-Foundation/psf-bch-api) REST API, and the infrastructure provided by [FullStack.cash](https://fullstack.cash). The `restURL` property can be changed to work with different Bitcoin Cash networks:
2020-07-27 21:32:51 -07:00
- BCHN Mainnet REST API server: https://bchn.fullstack.cash/v6/
- ABC Mainnet REST API server: https://abc.fullstack.cash/v6/
2020-11-08 18:49:45 -08:00
- Check server status: https://metrics.fullstack.cash
2020-07-27 21:32:51 -07:00
2022-04-30 16:04:22 -07:00
### API Key (JWT Token)
2020-11-08 18:56:48 -08:00
The [psf-bch-api](https://github.com/Permissionless-Software-Foundation/psf-bch-api) REST API hosted by [FullStack.cash](https://fullstack.cash) uses JWT tokens to pay for increased
2022-04-30 16:04:22 -07:00
rate limits when interacting with the back end server. See [this article](https://cashstack.info) if you want to understand the system-as-a-whole. The JWT token can be fed to bch-js _implicitly_ or _explicitly_.
2020-07-27 21:32:51 -07:00
2020-11-08 18:56:48 -08:00
- Implicitly: bch-js will detect your JWT token if you set the `BCHJSTOKEN` environment variable.
2020-07-27 21:32:51 -07:00
- Explicitly: You can directly feed in the JWT token with the `apiToken` property when instantiating the library. Here is an example:
```javascript
import BCHJS from "@psf/bch-js"
2020-07-27 21:32:51 -07:00
let bchjs = new BCHJS({
restURL: 'https://bchn.fullstack.cash/v6/',
2020-07-27 21:32:51 -07:00
apiToken: 'eyJhbGciO...' // Your JWT token here.
})
```
2022-04-30 16:04:22 -07:00
### Gatsby & Web Apps
2020-11-08 18:56:48 -08:00
2022-04-30 16:04:22 -07:00
[minimal-slp-wallet](https://www.npmjs.com/package/minimal-slp-wallet) is a minimal wallet 'engine' that incorporates bch-js. It's compiled with Browserify for front end apps.
2020-11-08 18:56:48 -08:00
2022-04-30 16:04:22 -07:00
[gatsby-theme-bch-wallet](https://github.com/Permissionless-Software-Foundation/gatsby-theme-bch-wallet) is a Gatsby Theme and [bch-wallet-starter](https://github.com/Permissionless-Software-Foundation/bch-wallet-starter) is a Gatsby Starter for building web wallets using minimal-slp-wallet.
2020-07-27 21:32:51 -07:00
2022-04-30 16:04:22 -07:00
[This gist](https://gist.github.com/christroutner/6cb9d1b615f3f9363af79723157bc434) shows how to include minimal-slp-wallet into a basic web page without using a framework.
2020-11-08 18:56:48 -08:00
2020-07-27 21:32:51 -07:00
## Features
- [ECMAScript 2017 standard JavaScript](https://en.wikipedia.org/wiki/ECMAScript#8th_Edition_-_ECMAScript_2017) used instead of TypeScript. Works
2020-11-08 18:56:48 -08:00
natively with node.js v10 or higher.
2020-07-27 21:32:51 -07:00
2022-04-30 16:04:22 -07:00
- Full SLP tokens support: bch-js has full support for all SLP token functionality, including send, mint, and genesis transactions. It also fully supports all aspects of [non-fugible tokans (NFTs)](https://www.youtube.com/watch?v=vvlpYUx6HRs).
2020-07-27 21:32:51 -07:00
- [Semantic Release](https://github.com/semantic-release/semantic-release) for
2020-11-08 18:56:48 -08:00
continuous delivery using semantic versioning.
2020-07-27 21:32:51 -07:00
2022-04-30 16:04:22 -07:00
- [IPFS](https://ipfs.io) and [Radicle](https://radicle.xyz) uploads of all files and dependencies, to backup
2020-11-08 18:56:48 -08:00
dependencies in case they are ever inaccessible from GitHub or npm.
2020-07-27 21:32:51 -07:00
## Documentation:
Full documentation for this library can be found here:
2020-11-08 18:56:48 -08:00
- [Documentation](https://bchjs.fullstack.cash/)
2020-07-27 21:32:51 -07:00
bch-js uses [APIDOC](http://apidocjs.com/) so that documentation and working code
live in the same repository. To generate the documentation:
2020-11-08 18:56:48 -08:00
2020-07-27 21:32:51 -07:00
- `npm run docs`
- Open the generated `docs/index.html` file in a web browser.
## Support
2020-11-08 18:56:48 -08:00
2020-07-27 21:32:51 -07:00
Have questions? Need help? Join our community support
[Telegram channel](https://t.me/bch_js_toolkit)
2022-04-30 16:07:17 -07:00
## Donate
This open source software is developed and maintained by the [Permissionless Software Foundation](https://psfoundation.cash). If this library provides value to you, please consider making a donation to support the PSF developers:
<div align="center">
<img src="./img/donation-qr.png" />
<p>bitcoincash:qqsrke9lh257tqen99dkyy2emh4uty0vky9y0z0lsr</p>
</div>
2022-04-30 19:37:30 -07:00
## IPFS & Radicle Releases
2020-07-27 21:32:51 -07:00
2020-11-10 08:24:19 -08:00
Copies of this repository are also published on [IPFS](https://ipfs.io).
2020-07-27 21:32:51 -07:00
2022-04-30 19:37:30 -07:00
- v6.2.10: `bafybeifsioj3ba77u2763nsyuzq53gtbdxsnqpoipvdl4immj6ytznjaoy`
- (with dependencies, node v14.18.2 and npm v8.8.0): `bafybeihfendd4oj6uxvvecm7sluobwwhpb5wdcxhvhmx56e667nxdncd4a`
They are also posted to the Radicle:
- v6.2.10: `rad:git:hnrkkroqnbfwj6uxpfjuhspoxnfm4i8e6oqwy`
2020-07-27 21:32:51 -07:00
## License
2020-11-08 18:56:48 -08:00
2020-07-27 21:32:51 -07:00
[MIT](LICENSE.md)