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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@rootblocks/trn-listener

v0.1.1

Published

A simple listener for The Root Network

Downloads

4

Readme

trn-listener

A simple listener for The Root Network (TRN) blockchain.

Installation

via NPM:

npm install @rootblocks/trn-listener

via Yarn:

yarn add @rootblocks/trn-listener

Usage

Basic Usage

import { Listener, NetworkName } from "@rootblocks/trn-listener";

const listener = new Listener({
  logLevel: "info",
  network: NetworkName.ROOT,
});

// Initialize the listener
listener.init().then(() => {
  // Listen to events in real-time
  listener.on([
    {
      section: "nft",
      method: "CollectionCreate",
      filter: {
        collectionOwner: "0xfffFFfFF000000000000000000000000000043D3",
      },
      callback: (event, metadata) => {
        console.log("Event data:", event);
        console.log("Block metadata:", metadata);
      },
    },
  ]);
});

Parse Single Block

// Parse a specific block
listener.parseOneBlock(
  "0xb5af318da1095e813b37368b8ac277821ecc975acd33aa8583a9200c2b910690",
  [
    {
      section: "nft",
      method: "CollectionCreate",
      filter: {
        collectionUuid: 1006692,
      },
      callback: (event, metadata) => {
        console.log("Found event in block:", event);
      },
    },
  ]
);

Custom Provider

import { WsProvider } from "@polkadot/api";

const provider = new WsProvider("wss://your-custom-endpoint.com");

const listener = new Listener({
  logLevel: "debug",
  network: NetworkName.PORCINI,
  customProvider: provider,
});

Event Filtering

The listener supports flexible event filtering. You can listen to any blockchain event by specifying:

  • section: The pallet/module name (e.g., "nft", "assets", "balances")
  • method: The specific event method (e.g., "CollectionCreate", "Transfer", "Mint")
  • filter: Object to filter events based on event data properties
  • callback: Function called when matching events are found

Configuration

  • logLevel: The log level for the listener (e.g., "info", "debug", "error"). Default: info.
  • network: The network to listen to. Can be NetworkName.ROOT or NetworkName.PORCINI.
  • customProvider: Optional custom WebSocket provider for connecting to specific endpoints.

Methods

  • init(): Initialize the connection to the blockchain. Returns a Promise.
  • on(eventsOfInterest): Subscribe to real-time events.
  • parseOneBlock(hash, eventsOfInterest): Parse events from a specific block.
  • hasSubscribed(): Check if the listener is currently subscribed to events.
  • stop(): Disconnect from the blockchain.