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

@hyperdivision/eth-transaction-indexer

v2.1.1

Published

Tails transactions on the Ethereum blockchain and indexes them in a Hyperbee

Downloads

10

Readme

eth-transaction-indexer

Tails transactions on the Ethereum blockchain and indexes them in a Hyperbee

npm install @hyperdivision/eth-transaction-indexer

Usage

const Indexer = require('eth-transaction-indexer')

const testnet = 'https://ropsten.infura.io/v3/2aa3f1f44c224eff83b07cef6a5b48b5'
const feed = hypercore('./path/to/storage')

// start indexing from block number
const beginAt = 0x899b00

const index = new Indexer(feed, {
  endpoint: testnet
})

// start the indexer
index.start()

// add an address to the index
index.add('0xdea..dbeef')

// get a stream of all the transactions paying to an address
const txns = index.createTransactionStream('0xdea..dbeef')

for await (let tx of txns) console.log(tx)

API

const index = new Indexer(feed, opts)

Instantiate a new index. Transactions of interest are logged in a Hyperbee written to the hypercore passed in as feed. endpoint should be an Ethereum HTTP API. defaultSeq gives the block number from which to start indexing from.

const opts = {
  endpoint: 'http://...',  // chain backend API
  defaultSeq: 9259777 // start from here if nothing has been stored. defaults to latest
}

index.start()

Start tailing the blockchain.

index.add(addr, [options])

Begin tracking transactions paying to addr. The initial balance of the address will be stored under the key !addr!<addr>, subsequent transactions will be added under the key !tx!<addr>!<block_number>!<tx_number>.

If you are tracking an ERC20 token, pass { token: <token-addr> } as well.

const str = index.createTransactionStream(addr)

Retrieve all transactions paying to the address given by addr. Returns an live stream of the time ordered transactions with the address' initial balance inserted before the first transaction.

The initial balance is inserted as a tx of the form:

{
  value: 0x4572e2,      // initial balance of the address
  blockNumber: 0x899b00 // block number at which the indexer began tracking the address
}

Other transactions are full eth transaction objects:

{
  blockHash: '0x277dfee78f6b1d8e495e7c25c95e0f2dc36a4ca772b32aa7b1ae7107f21d1351',
  blockNumber: '0x899f1b',
  from: '0x301b695ae7ba03b63828b6668232063bd4c9e0bc',
  gas: '0x5208',
  gasPrice: '0x7aef40a00',
  hash: '0x7cde8e856bf1c73146c64054f0e74acdd05d7ba351693c6aaeca620bcdcfc03e',
  input: '0x',
  nonce: '0x16',
  r: '0xf38ed059c881c3079d445081c09e6f0df7cfa5fa9be1cb830b479fbb1a0327c8',
  s: '0x63830c84ef2b177d9ec488eeb32215363364aa7aade743c403d2a06686b7fc95',
  to: '0x50c7d91e74b0e42bd8bce8ad6d199e4a23c0b193',
  transactionIndex: '0x0',
  v: '0x2a',
  value: '0x5af3107a4000'
}