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

demux-ala

v4.0.2

Published

Demux-js Action Reader implementations for ALAIO blockchains

Readme

demux-js-ala Build Status

Demux Action Reader implementations to read block and action data from ALAIO-based blockchains.

Installation

# Using yarn
yarn add demux-ala

# Using npm
npm install demux-ala --save

Usage

This library provides three Action Reader implementations for reading from ALAIO blockchains: AlanodeActionReader, MongoActionReader, and StateHistoryPostgresActionReader. It is currently recomended to use the MongoActionReader due to performance and the ability to read inline and deferred actions.

MongoActionReader

Reads from a node's attached MongoDB instance when configured to use the MonogoDB Plugin.

Setup

To use the MongoActionReader, you must first make sure that your environment is properly configured, as it otherwise may yield unpredictable or incorrect results. To set up a proper environment, make sure the following are true:

  • The node that has the MongoDB plugin activated:
    • Is not producing blocks
    • Is connected to the node(s) producing blocks via the p2p-peer-address configuration
    • Has the read-mode configuration set to read-only
    • Has the mongodb-update-via-block-num configuration enabled

This means that in a development environment, you will need to set up at least two Alanode instances: one to produce blocks, and a peer with the MongoDB plugin activated to populate the attached MongoDB.

For performance, the following settings are also recommended:

  • Since the only collections utilized are the block_states and action_traces, we can save space by not indexing any of the other collections via setting the following options to false:
    • mongodb-store-blocks
    • mongodb-store-transactions
    • mongodb-store-transaction-traces
  • Use the mongodb-filter-out option to isolate which accounts/actions you are indexing to only the actions you are listening for in your Action Handler. This will further reduce space requirements, and may give a performance boost via faster queries and less data for the Action Handler to process. For more information on how to filter, see the MongoDB Plugin documentation.

Inline and Deferred Actions

Unlike the AlanodeActionReader, inline and deferred actions are able to be captured and passed on to the Action Handler. Additionally, each Action has a notifiedAccounts property that lists all accounts notified of the blockchain action (this information is also not available via the AlanodeActionReader).

Example

const { BaseActionWatcher } = require("demux")
const { MongoActionReader } = require("demux-ala")

// See supported Action Handlers here: https://github.com/ALADIN-Network/demux-js#class-implementations
const actionHandler = ...

const actionReader = new MongoActionReader({
  startAtBlock: 1234,              // startAtBlock: the first block relevant to our application
  onlyIrreversible: false,         // onlyIrreversible: whether or not to only process irreversible blocks
  dbName: "ALA",                   // name of the database
  mongoEndpoint: "mongo://...",    // mongoEndpoint: the url of the mongodb instance
})

const actionWatcher = new BaseActionWatcher(actionReader, actionHander, 500)

// This must be done before calling watch so the MongoDB connection can be made
actionReader.initialize().then(() =>
  actionWatcher.watch()
)

StateHistoryPostgresActionReader

Reads from a Postgres instance when alanode is configured to use the State History Plugin as well as the fill-postgresql tool.

Setup

To use the StateHistoryPostgresActionReader, you must first make sure that your environment is properly configured, as it otherwise may yield unpredictable or incorrect results. To set up a proper environment, make sure the following are true:

  • You are running a producing node.

  • You are running a second node with the state history plugin enabled.

    • Is not producing blocks
    • Is connected to the node(s) producing blocks via the p2p-peer-address configuration
    • --disable-replay-opts set via CLI.
    • --plugin alaio::state_history_plugin set via CLI.
    • --trace-history set via CLI.
    • --chain-state-history set via CLI.
    • --state-history-endpoint \"0.0.0.0:<preferred_port>\" set via CLI.
  • You are running fill-postgresql.

    • --endpoint=<ip_of_above_node:port_specified> set via CLI.
    • --schema=<preferred_schema> set via CLI.
    • --drop set via CLI. This will cleanup any existing tables.
    • --create set via CLI. This will create the schema/tables as needed.

This means that in a development environment, you will need to set up at least two Alanode instances: one to produce blocks, and a peer with the State History plugin activated to populate the Postgresql instance.

Inline and Deferred Actions

Unlike the AlanodeActionReader, inline and deferred actions are able to be captured and passed on to the Action Handler. Additionally, each Action has a notifiedAccounts property that lists all accounts notified of the blockchain action (this information is also not available via the AlanodeActionReader).

Example

const { BaseActionWatcher } = require("demux")
const { StateHistoryPostgresActionReader } = require("demux-ala")

// See supported Action Handlers here: https://github.com/ALADIN-Network/demux-js#class-implementations
const actionHandler = ...

const massiveConfig = {
  host: 'localhost',
  port: 5432,
  database: 'chain',
  user: 'postgres',
  password: 'postgres'
}

const actionReader = new StateHistoryPostgresActionReader({
  startAtBlock: 1234,              // startAtBlock: the first block relevant to our application
  onlyIrreversible: false,         // onlyIrreversible: whether or not to only process irreversible blocks
  dbSchema: "chain",               // name of the database
  massiveConfig,                   // provides config to internal massivejs instance.
})

const actionWatcher = new BaseActionWatcher(actionReader, actionHander, 500)

// This must be done before calling watch so the MongoDB connection can be made
actionReader.initialize().then(() =>
  actionWatcher.watch()
)

AlanodeActionReader

Makes requests directly to a specified Alanode API endpoint to obtain block data.

Setup

All that is required is a running Alanode instance that has the chain_api_plugin enabled.

Example

const { BaseActionWatcher } = require("demux")
const { AlanodeActionReader } = require("demux-ala")

// See supported Action Handlers here: https://github.com/ALADIN-Network/demux-js#class-implementations
const actionHandler = ...

const actionReader = new AlanodeActionReader({
  startAtBlock: 1234,             // startAtBlock: the first block relevant to our application
  onlyIrreversible: false,        // onlyIrreversible: whether or not to only process irreversible blocks
  alanodeEndpoint: "http://...",   // mongoEndpoint: the url of the Alanode API
})

const actionWatcher = new BaseActionWatcher(actionReader, actionHander, 500)

actionWatcher.watch()