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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ethereum-events-do

v0.0.8

Published

Event Engine For Ethereum

Readme

An ethereum event stream based on cloudflare worker and durable object

Use

install

npm i ethereum-events-do

extend EthereumEventsDO and implement onEventStream

/// MyEthereumEventsDO.ts
import { EthereumEventsDO, EventWithId } from 'ethereum-events-do';

export class MyEthereumEventsDO extends EthereumEventsDO {

  constructor(state: DurableObjectState, env: Env) {
    super(state, env);
  }

  onEventStream(eventStream: EventWithId[]) {
    // TODO whatever you want
  }

  // optionaly you can add more endpoint, like a normal DO
  async fetch(request: Request): Promise<Response> {
    ...
    return super.fetch(request);
  }

}

Example: the websocket implementation

hook it up in the worker

Indeed, as a Durable Object you still need to hook its request from the worker like so for example:

/// worker.ts
export default {
  async fetch(
    request: Request,
    env: Env,
    ctx: ExecutionContext,
  ): Promise<Response> {
    switch (new URL(request.url).pathname) {
      case '/events/setup':
      case '/events/list':
        // we only need one DO so we use _GLOBAL_ id
        const namespace = env.ETHEREUM_EVENTS;
        const DO = namespace.get(namespace.idFromName('_GLOBAL_'));

        return DO.fetch(request);
      }
      default:
        return new Response('Not found', { status: 404 });
    }
  },
};

// TODO rename

export { MyEthereumEventsDO as EthereumEventsDO } from './MyEthereumEventsDO';

This is just for demonstration purpose, admin checks need to be set for setup

  • setup expect to be called once with the contract data. then the durable object will call itself and fetch the events for these, store then and call onEventStream
  • list is simply a getter to fetch the event, you might not want to expose it. it accept 2 get param start and limit

You also need to export its class (as shown above) and declare it in the wrangler.toml (See cloudflare doc)

for example:

...
[durable_objects]
bindings = [{name = "ETHEREUM_EVENTS", class_name = "EthereumEventsDO"}]
...

frequency of updates

By default the DO use cloudflare worker alarm and these are called every 30s at max. To disable the alarm : EthereumEventsDO.alarm = null; To set a specific interval that the DO will try to perform : EthereumEventsDO.alarm = { interval: 6 };

If you disable the alarm, the events won't be processed. the DO also expose a process endpoint and you can call it in a worker CRON handler instead CRON have a resolution of 1 minite so you ll need to also call it several time

The DO can do that for your automatically via : EthereumEventsDO.scheduled = {interval: 6}

You could also trigger it externaly. Technically it is idemptotent so there should be no need to protect it behind authentication even

Development

install dev env

pnpm i

Websocket tests

To test

in one console:

pnpm dev

in another :

pnpm ts-node scripts/test.ts

then you can use a websocket tool (like https://chrome.google.com/webstore/detail/websocket-test-client/fgponpodhbmadfljofbimhhlengambbn) on ws://localhost:8787/websocket and connect and see the stream of event