New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

watch-eth

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

watch-eth

Robust library for listening to Ethereum events

latest
npmnpm
Version
0.0.1-beta.7
Version published
Maintainers
1
Created
Source

watch-eth

watch-eth is a robust library for watching Ethereum events. Applications sometimes make critical decisions based on Ethereum events. It's therefore important that these applications have a way to watch for events that won't fail.

Installation

npm

You can install watch-eth via npm:

npm install --save watch-eth

Usage

Start by creating an EventWatcher instance for your contract:

const { EventWatcher } = require('watch-eth')

const watcher = new EventWatcher({
  address: '0xc8a5ba5868a5e9849962167b2f99b2040cee2031',
  abi: [{"anonymous":false,"inputs":[{"indexed":false,"name":"_value","type":"uint256"}],"name":"TestEvent","type":"event"}],
  finalityDepth: 12   // optional
  pollInterval: 10000 // optional
})

Now you can subscribe or unsubscribe to an event:

const listener = () => {
  console.log('Detected TestEvent!')
}

watcher.subscribe('TestEvent', listener)
// Stuff
watcher.unsubscribe('TestEvent', listener)

Design

Modularity

watch-eth is designed to be modular, meaning most of the components can be replaced with custom logic. For example, if you want to use ethers for connecting to Ethereum instead of web3, you can simply replace DefaultEthProvider with a custom class.

Event Validity Conditions

watch-eth will only relay an Ethereum event if it satisfies the following conditions:

  • Event has not been seen before.
  • Event is under a certain number of blocks.

Keywords

ethereum

FAQs

Package last updated on 04 Mar 2019

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