bufnita
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

🦉 Bufnița

Bufnița is a contract observer and indexer library, that reads events from a web3 provider, stores them into a MongoDB database, notify them to webhooks and execute callbacks.

1. Usage

Bufnița can be used as library or as command line interface.

1.1 Command Line Interface

# Installation
npm i -g bufnita

# Execution

bufnita [manifest-file, default=manifest.yml]

1.2 Library

// Typescript
import Bufnita from "bufnita";
// Javascript
const Bufnita = require("bufnita");

Bufnita.create(options).then(() => {
	console.log("Observer has been initialized.");
});

1. Manifest File / Bufnița Options

The manifest file and Bufnița options share the same schema, but they are in different situations. Manifest file is the input for the command line, and the Bufnița options object is the input for the Bufnița library.

interface  IManifest {
	version:  string; // Version = "1"
	mongoUrl:  string; // MongoDB URL to connect
	web3Rpc:  string; // Web3 RPC to connect, websockets recommended
	interval?:  number; // How many time between http requests (Http web3rpc only)
	
	contracts?: { // Contracts to observe
		[contractName:  string]:  { // Contract Name
			address:  string; // Contract Address
			events?:  string[] // Events to Observe, All by default
			abi:  string; // ABI Json File Path
			callbacks?: { // Not available in yml, callbacks
				[event:  string]: (data:  any) =>  any // Callbacks are executed by event name
			}
		}
	}
	
	collections?: { // Mongodb data where events & contract meta will be stored
		events?:  string; // default = bufnita-events
		contracts?:  string; // default = bufnita-contracts
	}
	
	rsa?: { // RSA Keys to sign webhooks, default = no signature
		priv:  string; // Path to rsa priv key
		pub:  string; // Path to rsa pub key
	}
	
	webhooks?:  string[]; // List of url where events will be notified
}

3. Flowchart

enter image description here

/bufnita/

    Package Sidebar

    Install

    npm i bufnita

    Weekly Downloads

    1

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    48.6 kB

    Total Files

    45

    Last publish

    Collaborators

    • ctorresc