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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@psf/bch-js

v7.1.1

Published

A JavaScript library for working with Bitcoin Cash and SLP Tokens

Readme

bch-js

Version Downloads/week License js-standard-style Join the chat at https://gitter.im/Permissionless-Software-Foundation/bch-js

bch-js is a JavaScript npm library for creating web and mobile apps that can interact with the Bitcoin Cash (BCH) blockchain. bch-js contains a toolbox of handy tools, and an easy API for talking with psf-bch-api REST API. FullStack.cash offers paid cloud access to psf-bch-api. You can run your own infrastructure by following documentation on CashStack.info.

Quick Start Videos:

YouTube walk-through videos to help you get started:

Quick Links

Quick Notes

  • Install library: npm install @psf/bch-js

  • Instantiate the library in your code:

import BCHJS from "@psf/bch-js"
let bchjs = new BCHJS() // Defaults to BCHN network.

This library is intended to be paired with the psf-bch-api REST API, and the infrastructure provided by FullStack.cash. The restURL property can be changed to work with different Bitcoin Cash networks:

  • BCHN Mainnet REST API server: https://x402-bch.fullstack.cash/v7/
  • Check server status: https://metrics.fullstack.cash

Configuration

bch-js can be configured through constructor options or environment variables. Configuration options passed to the constructor take precedence over environment variables.

Constructor Options

When instantiating BCHJS, you can pass a configuration object:

import BCHJS from "@psf/bch-js"

const bchjs = new BCHJS({
  restURL: 'https://x402-bch.fullstack.cash/v5/',
  bearerToken: 'your-bearer-token',
  wif: 'your-private-key-wif',
  paymentAmountSats: 20000,
  bchServerURL: 'https://bch.fullstack.cash'
})

Configuration Options

| Option | Type | Required | Default | Description | |--------|------|----------|---------|-------------| | restURL | string | Yes* | - | The REST API server URL for making API calls. Must include trailing slash. *Required unless RESTURL environment variable is set. | | bearerToken | string | No | '' | Bearer token for authentication with the REST API server. | | wif | string | No | '' | Private key in WIF format. When provided, enables automatic x402 payment handling. | | paymentAmountSats | number | No | 20000 | Default amount of satoshis to send when making x402 payments. | | bchServerURL | string | No | 'https://bch.fullstack.cash' | BCH server URL used for broadcasting payment transactions to the blockchain. This is separate from restURL and is specifically for x402 payment processing. |

Environment Variables

You can also configure bch-js using environment variables:

| Environment Variable | Config Option | Description | |---------------------|---------------|-------------| | RESTURL | restURL | REST API server URL for making API calls. | | BCHJSBEARERTOKEN | bearerToken | Bearer token for API authentication. | | BCHJSWIF | wif | Private key in WIF format for x402 payments. | | BCHJSBCHSERVERURL | bchServerURL | BCH server URL for x402 payment transactions. |

Understanding restURL vs bchServerURL

These two configuration options serve different purposes:

  • restURL: The REST API server used for all regular API calls (utxo queries, transaction history, etc.). This can be any bch-api compatible server, such as https://x402-bch.fullstack.cash/v5/ or https://bch.fullstack.cash/v5/.

  • bchServerURL: The BCH infrastructure server used specifically for broadcasting x402 payment transactions to the blockchain. This defaults to https://bch.fullstack.cash and should typically remain unchanged unless you have specific infrastructure requirements.

Example Use Case: Most users will use https://x402-bch.fullstack.cash/v5/ as their restURL to access x402-protected APIs. However, when bch-js needs to make an x402 payment, it uses the bchServerURL (default: https://bch.fullstack.cash) to broadcast the payment transaction. This ensures payment transactions are sent through a reliable BCH infrastructure endpoint.

// Use x402-bch server for API calls, but bch.fullstack.cash for payments
const bchjs = new BCHJS({
  restURL: 'https://x402-bch.fullstack.cash/v5/',
  wif: 'your-private-key-wif'
  // bchServerURL defaults to 'https://bch.fullstack.cash'
})

// Or explicitly set both
const bchjs2 = new BCHJS({
  restURL: 'https://x402-bch.fullstack.cash/v5/',
  bchServerURL: 'https://bch.fullstack.cash',
  wif: 'your-private-key-wif'
})

Web Apps

minimal-slp-wallet is a minimal wallet 'engine' that incorporates bch-js. It's compiled with Browserify for front end apps.

This gist shows how to include minimal-slp-wallet into a basic web page without using a framework.

bch-wallet-web3-spa is a React web app template using bch-js and minimal-slp-wallet.

Features

  • ECMAScript 2017 standard JavaScript 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 supports all aspects of non-fugible tokans (NFTs).

  • Semantic Release for continuous delivery using semantic versioning.

  • IPFS and Radicle uploads 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:

bch-js uses APIDOC 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

Donate

This open source software is developed and maintained by the Permissionless Software Foundation. If this library provides value to you, please consider making a donation to support the PSF developers:

IPFS & Radicle Releases

Copies of this repository are also published on IPFS.

  • 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

License

MIT