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

@digicat/ethereum-contract-watcher

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@digicat/ethereum-contract-watcher

Observes contracts on a web3.js-compatible Ethereum network, providing callbacks for when events are emitted

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

@digicat/ethereum-contract-watcher

This package can observe contracts on a web3.js-compatible Ethereum network, providing callbacks for when events are emitted. Requires Node.js 8.6 or newer.

Usage

const ContractWatcher = require('@digicat/ethereum-contract-watcher')

const watcher = new ContractWatcher({
  ethereumNode: 'http://localhost:8545',

  onError (err, token) {
    // Called when an error occurred. Expected to be synchronous.
  },

  onEvent (event, token) {
    // Called when an event occurs for a contract that's being watched.
    //
    // Can be asynchronous (if you return a promise). Won't interleave with
    // other events.
    //
    // The `event` object comes directly from Web3.
    // See <https://github.com/ethereum/wiki/wiki/JavaScript-API#contract-events>.
  },

  wrapWeb3Error (err) {
    // Allows for underlying Web3 errors to be wrapped in another Error class.
    // By default returns the error as-is.
    return err
  }
})

// Start watching a new contract. The `token` is provided in callbacks as-is.
watcher.add({
  // ABI array of the contract (required).
  abi: […],
  // Contract address (required, no default value).
  address: '0xef3b47f7e4865c72565f448cc162945ea5bcdc1e'
  // The block from which events should be observed. Defaults to 'latest'.
  fromBlock: 'latest',
  token: {
    an: {
      arbitrary: 'object'
    }s
  }
})

// Stop watchers all contracts.
watcher.stop()

Keywords

FAQs

Package last updated on 17 Oct 2017

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