bap-planaria
v1.0.13
Published
BAP indexer to MongoDB
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-planariaSet 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-planariaIf you want to run continuously and also listen to the mempool, run:
bap-planaria -a watchIt'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 bobThe 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.gitBAP-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.shTo run the indexer in watch mode, which also indexes all transactions in the mempool:
./watch.shtesting
npm run testor
npm run testwatchIncluding in your own package or site
npm install bap-planariaMake 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.
