Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bap-planaria

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bap-planaria

BAP indexer to MongoDB

  • 1.0.13
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

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:

argDescription
-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.

Keywords

FAQs

Package last updated on 26 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc