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

web3-events-db

v0.0.3

Published

Easily store web3 events to a database of your choice without the normal painful scaffolding.

Downloads

4

Readme

web3-events-db

Easily store blockchain events from smart contracts to a database of your choice without doing all the painful scaffolding.

Install

$ npm install -s web3-events-db

Built-in Database Connectors

Please add an issue for any common, modern DB you'd like us to support with a built-in connector.

  • PostgreSQL
  • MongoDB

Usage

See Examples for good small example scripts to get you started.

Example 1: BSC verified contract to PostgreSQL DB

import web3EventsDb from 'web3-events-db'

// listen for events for a bscscan verified BSC contract and populate a postgres database
// listening on localhost and in default table `Predict_web3_events_db` (`${eventName}_web3_events_db`)
const readerWriter = Web3EventsDb({
  db: {
    type: 'postgres',
    connectionString: 'postgres://localhost:5432/web3',
  },
  contract: {
    network: 'bsc',
    blockExplorerApiKey: process.env.BSCSCAN_API_KEY,
    wsRpc: `wss://mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`,
    contract: '0x20D0a1831c0F5071904a5EC511423564793bf620',
    eventName: 'Predict',
  },
  recordCallback: (record) => console.log('got a record', record),
})
await readerWriter.start()

Example 2: BSC contract w/ custom passed ABI to PostgreSQL DB

TODO

Example 3: BSC verified contract to MongoDB

TODO

Example 3: BSC verified contract to PostgreSQL DB with overriden table name

TODO

Example 3: BSC verified contract to custom DB connector

TODO

Testing

Tests depend on active database connections on localhost for all built-in connectors (mongodb and postgres).

$ npm test