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 🙏

© 2024 – Pkg Stats / Ryan Hefner

bch-nostr

v1.2.0

Published

Utility library for interaction between BCH and Nostr.

Downloads

255

Readme

bch-nostr

This is an node.js npm library for interactions between BCH and Nostr. Here are some of the things this library allows you to do:

  • Generate a Nostr npub address with a BCH private key.
  • Send E2EE messages to a BCH address. Store the encrypted message on Nostr.
  • Check a BCH address to see it is has received E2EE messages.
  • Download and decrypt messages stored on Nostr.

Installation

  • npm install --save bch-nostr

Include the library in your JavaScript app:

import BchNostr from 'bch-nostr'
const bchNostr = new BchNostr()

Examples

Below are examples of how this library can be consumed.

Generate Nostr pubkey from WIF private key

The WIF format is the standard format for private keys in BTC and BCH. You can use the private key of your cryptocurrency wallet to generate a Nostr pubkey for creating a user and posting messages.

const wif = 'L2HJYqrXgsVghD5fXQZY2X4upFuvvnmF9o3cF3s3AuDix3FzbcB1'
const {privKeyBuf, nostrPubKey} = bchNostr.keys.createNostrPubKeyFromWif({wif})

// privKeyBuf is the raw private key as a 32-byte Uint8Array
console.log(nostrPubKey)
// '8f97b3b776631f7504c000cff2740e3ba08f928522d45c57ce95d6a3bcbeec6e'

Post a message to a Nostr Relay

// Generate a key pair
const wif = 'L2HJYqrXgsVghD5fXQZY2X4upFuvvnmF9o3cF3s3AuDix3FzbcB1'
const {privKeyBuf, nostrPubKey} = bchNostr.keys.createNostrPubKeyFromWif({wif})

const relayWs = 'wss://nostr-relay.psfoundation.info'

const msg = "test message"

const inObj = {privKeyBuf, nostrPubKey, relayWs, msg}
const eventId = await bchNostr.post.uploadToNostr(inObj)

// eventId: '770efaf6c8d0b239a7f3a49e74e55f7fa40d7b9d6ec7760db52f3ade3f3d72b9'

Dev Environment

Follow these instruction to setup a dev environment. Ensure node.js v20+ is installed.

  • git clone https://github.com/Permissionless-Software-Foundation/bch-nostr
  • cd bch-nostr
  • npm install
  • npm test

Resources

To see more JS examples of how to interact with a Nostr relay, check out the nostr-sandbox.

To meet other JS devs who are interested in the intersection of cryptocurrency and Nostr, visit this Telegram channel.

This library is consumed by:

  • psf-msg-wallet - command-line interface (CLI) for sending encrypted messages to BCH addresses.

Pedigree

This repository was originally forked from the npm-lib-boilerplate-esm boilerplate.

Licence

MIT