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

bap-planaria

v1.0.13

Published

BAP indexer to MongoDB

Downloads

58

Readme

bap-planaria

BAP transaction indexer

BAP-planaria is a Bitbus compatible Bitcoin Attestation Protocol indexer. It scans all BAP transactions and processes them into a global BAP state using the bitsocket.network servers.

NOTE: This is still work in progress and should be considered beta software. Issues / requests and PR's are welcome.

global installation

npm install -g bap-planaria

Set the environment variables. You must at least set the planaria token.

export BAP_PLANARIA_TOKEN=""

The token is a Planaria Token that can be created here: https://token.planaria.network/

And optionally overwrite the defaults for the database:

export BAP_MONGO_URL="mongodb://localhost:27017/bap-planaria"

Indexing BAP blocks can now be done by running

bap-planaria

If you want to run continuously and also listen to the mempool, run:

bap-planaria -a watch

It's also possible to get transactions directly from bitbus with the bap-planaria cli

bap-planaria -a get -t <txId>

Or run a query for at most 10 transactions

bap-planaria -a get -q '{"out.tape.cell":"1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT"}' -p bob

The arguments to the bap-planaria cli are:

| arg | Description | | --------------- |------------------------------------------------------------------------------------------------------- | | -a <action> | Action to call (index (default), watch, get) | | -t <txId> | Transaction Id to search for. Only works together with -a get | | -q <query> | JSON stringified query. Only works together with -a get | | -p <parser> | Parser to use for the returned transaction (txo (default), bob). Only works together with -a get |

local installation

git clone https://github.com/icellan/bap-planaria.git

BAP-planaria can run either with settings from a config file (config.json) or from environment variables.

config.json

{
  "token": "ey...",
  "mongoUrl": "mongodb://..."
}

environment

export BAP_PLANARIA_TOKEN="ey..."
export BAP_MONGO_URL="mongo://..."

run

To run the indexer once to index all blocks:

./start.sh

To run the indexer in watch mode, which also indexes all transactions in the mempool:

./watch.sh

testing

npm run test

or

npm run testwatch

Including in your own package or site

npm install bap-planaria

Make sure you set the environment variables before running any scripts:

export BAP_PLANARIA_TOKEN = '<planaria token>';
export BAP_MONGO_URL = 'mongodb://localhost:27017/bap-planaria';

Index all mined BAP transactions:

import { indexBAPTransactions } from 'bap-planaria/src/bap';

(async function() {
  await indexBAPTransactions();
})();

or, index all mined transactions + listen to the mempool:

import { watchBAPTransactions } from 'bap-planaria/src/watch';

(async function() {
  await watchBAPTransactions();
})();

You can also pass a custom query to the BAP scripts, overriding the default query that searches for BAP transactions.

import { watchBAPTransactions } from 'bap-planaria/src/watch';
import { BAP_BITCOM_ADDRESS } from 'bap-planaria/src/config';

(async function() {
  // this will only watch for new ID transactions
  await watchBAPTransactions({
    'out.s2': BAP_BITCOM_ADDRESS,
    'out.s3': 'ID'
  });
})();

Babel

Make sure babel is set up properly or that es6 is supported by your own package.