npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ethereum-transaction-stream

v1.1.0

Published

Relatime Ethereum transactions tracking library

Downloads

14

Readme

ethereum-transaction-stream

Relatime Ethereum transactions tracking library

Installation

npm install ethereum-transaction-stream

Features

  • Works in Node.js and browsers (incl. websocket fallback)
  • Fetches historical transactions besides realtime tracking
  • Handles transactions tracking for testnet (despite lack of Etherscan support)
  • Possibility to include internal transactions (per tx)
  • Possibility to include ERC20 tokens minting logs (per tx)

Usage

// import EthTS from 'ethereum-transaction-stream/dist/browser';
// import EthTS from 'ethereum-transaction-stream';
// const { EthTS } = window;
const EthTS = require('ethereum-transaction-stream');

(async (EthTS) => {
  const ets = EthTS

      // EthTS.PROVIDERS.Etherscan
      // EthTS.PROVIDERS.EtherscanWS
      // EthTS.PROVIDERS.EtherscanHTTP
      .create(EthTS.PROVIDERS.EtherscanWS)

      // EthTS.EtherscanConfig.MAINNET (default)
      // EthTS.EtherscanConfig.ROPSTEN
      // EthTS.EtherscanConfig.RINKEBY
      .configure('network', EthTS.EtherscanConfig.ROPSTEN)

      // Include internal txs (e.g. proxy value to another address)
      // Default: false
      .configure('includeInternal', true)

      // Include logs (e.g. token minting)
      // Important: this is currently available for EtherscanHTTP only
      // Default: false
      .configure('includeLogs', true);

  // Creates a new stream.
  // Note that "startblock", "endblock", "ERC20TokenAddress" and "mintOnly" options
  // are only available for "EtherscanHTTP" provider. By including "ERC20TokenAddress"
  // there will be included transactions for ERC20 token only and enabling "mintOnly"
  // option will result in leaving only token minting events.
  // Important: "ERC20TokenAddress" and "mintOnly" options are available only when "includeLogs" enabled
  // Important: the result will INCLUDE transactions from the "startblock"
  const stream = await ets.stream(
    '0x4a1eade6b3780b50582344c162a547d04e4e8e4a'
    /*, startblock, endblock, ERC20TokenAddress, mintOnly */
  );

  console.log('in use:', ets.streamInUse); // false

  const txs = [];

  // Subscribes to the stream.
  // There is a "const txs = await stream.waitAll()" method
  // however you should avoid it- it might hang your process (e.g. with ws provider)
  await stream.subscribe((tx) => {
    txs.push(tx);

    console.log('+1');
  });

  console.log('in use:', ets.streamInUse); // true

  // Keep alive the connection for 10 seconds
  await new Promise((resolve) => {
    setTimeout(async () => {
      await stream.close(); // or "await ets.close()" which is an alias
      resolve();
    }, 10000);
  });

  console.log('Transactions received:', txs.length);
})(EthTS);

Enabling includeInternal option might slow down the performance considerably

For more examples check out /example folder.

Testing

npm run test # npm run test:v|vvv for debugging

Roadmap

  • [ ] Add ERC20 tokens transfer fetching
  • [ ] Add custom events processing
  • [ ] Include logs into the native WS provider

Support development

I really love open source, however i do need your help to keep the library up to date. There are several ways to do it: open issues, submit PRs, share the library w/ community or simply-