Giter Site home page Giter Site logo

block-notifier's Introduction

block-notifier

Overview

Provide a standalone service, that can notify blockchain events via many channels

(listener) <-webhook- (notifier) <-filtered events- (watcher) <-crawled data- (blockchain network)

Packages:

  • block-notifier
  • base-watcher
  • eth-watcher
  • btc-watcher

Usage

Examples

const BlockNotifier = require('block-notifier');
const notifier = BlockNotifier.create({
  outputs: [
    {
      type: BlockNotifier.OUTPUT_TYPE.WEBHOOK,
      url: 'http://example.com'
    },
    {
      type: BlockNotifier.OUTPUT_TYPE.REDIS_PUBSUB,
      host: '127.0.0.1',
      ...
    }
  ]
});

const getWatchingAddresses = function(){...} // Method to get watching addresses with current logic.
const isWatchingTransaction = function(tx){...} // Method to filter out watching transaction
const EthWatcher = require('eth-watcher');
const events = [
  {
    type: EthWatcher.EVENT.TRANSFER,
    filter: EthWatcher.createFilter({toAddress: '0x140427a7D27144A4cDa83bD6b9052a63b0c5B589'})
  },
  {
    type: EthWatcher.EVENT.ERC20_TRANSFER,
    filter: EthWatcher.createFilter({
      tokenAddress: '0xd26114cd6EE289AccF82350c8d8487fedB8A0C07', // OmiseGO
      toAddress: getWatchingAddresses
    })
  },
  {
    type: EthWatcher.EVENT.TRANSFER,
    filter: EthWatcher.createFilter({txFilter: isWatchingTransaction})
  },
];
const watcher = EthWatcher.create({
  notifier,
  events,
});
watcher.start();

Classes

BaseWatcher

  • Can be extended to ETHWatcher, BTCWatcher, etc...
  • start() (void): ignite the engine
  • $create(WatcherConfig) (BaseWatcher): create watcher instance
  • $createFilter(FilterConfig) (BaseFilter): create events filter for watcher instance

FilterConfig

  • type: can be TRANSFER, ERC20_TRANSFER, ... (for Ethereum, there may be other values for other platform)

BlockNotifier

  • TBD...

block-notifier's People

Contributors

nhan-pt avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.