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

bcevents

v0.1.3

Published

Event emitter using blockchain transations

Downloads

6

Readme

bcevents

Sends and listens to events broadcasted on bitcoin transactions. Events can be used to trigger remote actions or send payloads to listeners.

Install

npm install bcevents datapay bsv

Get Started

var Emitter = require('bcevents')
var emitter = new Emitter({ pkey: 'private key for tx fees' })

emitter.on('my-event', console.log) // prints { ..., payload: 1234 }
emitter.emit('my-event', 1234, console.log) // prints tx hash

Protocol

Everytime emit() is called, a new transaction is broadcasted with the event and payload inside the OP_RETURN:

  • OP_RETURN
    • protocol_id
    • event
    • payload (optional)

The protocol Id should be set when creating emitters otherwise the events will be listened by any agent using the default protocol id.

emitter = new Emitter({ protocol: 'my-unique-protocol-id' })

Encryption

To Encrypt both event and payload on transactions, use the enkKey field. When set, transaction data will be encrypted and decrypted using AES.

var emitter = new Emitter({ encKey: 'my-password' })

To use a different encryption, both encrypt and decrypt function can be set:

var emitter = new Emitter({
  encrypt: (data) => myEncrypt(data),
  decrypt: (data) => myDecrypt(data)
})

Examples

Ping-Pong

// endless ping-pong between two agents
// oracle.js
var emitter = new Emitter({ pkey: 'oracle pkey', protocol: 'pingpongtest' })
emitter.on('ping' () => {
  emitter.emit('pong')
})

// client.js
var emitter = new Emitter({ pkey: 'client pkey', protocol: 'pingpongtest' })
emitter.on('pong', () => {
  emitter.emit('ping')
})
emitter.emit('ping').then(console.log)

Whitelisting

var whitelist = [addr1, addr2, ...] // addresses whitelist

emitter.on('some-event', (e) {
  if (!whitelist.includes(e.from)) {
    return
  }
  // ...
})