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

radix-transaction-stream

v0.2.4

Published

A utility package for streaming transactions from the Radix ledger in a reliable and efficient manner.

Readme

Radix Transaction Stream

A utility package for streaming transactions from the Radix ledger in a reliable and efficient manner.

Installation

npm install radix-transaction-stream

Features

  • Stream transactions from the Radix ledger with automatic state version management
  • Error handling for common issues like state version beyond known ledger
  • Configurable transaction batch size
  • Optional debug logging
  • Type-safe API with proper error handling using neverthrow

Usage

Basic Usage

import { createTransactionStream } from 'radix-transaction-stream'

// Create a transaction stream with default settings
const transactionStream = createTransactionStream()

// Process transactions in a loop
const processTransactions = async () => {
  while (true) {
    const result = await transactionStream.next()

    if (result.isErr()) {
      // Handle errors
      console.error('Error fetching transactions:', result.error)

      // Special handling for state version beyond known ledger
      if (
        'parsedError' in result.error &&
        result.error.parsedError === 'StateVersionBeyondEndOfKnownLedger'
      ) {
        console.log('Reached end of ledger, waiting for new transactions...')
        await new Promise((resolve) => setTimeout(resolve, 1000))
        continue
      }
    } else {
      // Process transactions
      const { stateVersion, transactions } = result.value
      console.log(
        `Processing ${transactions.length} transactions at state version ${stateVersion}`,
      )

      // Your transaction processing logic here
      for (const tx of transactions) {
        // Process each transaction
      }
    }
  }
}

processTransactions()

Advanced Configuration

import { createTransactionStream } from 'radix-transaction-stream'
import { createRadixNetworkClient } from 'radix-web3.js'

// Create a custom network client
const gatewayApi = createRadixNetworkClient({
  networkId: 1, // Mainnet
  // Other configuration options
})

// Create a transaction stream with custom settings
const transactionStream = createTransactionStream({
  gatewayApi, // Custom network client
  startStateVersion: 1000, // Start from a specific state version
  numberOfTransactions: 50, // Number of transactions to fetch per request
  debug: true, // Enable debug logging
  logLevel: 'debug', // Log level (debug, info, warn, error, trace)
})

// Use the transaction stream
const result = await transactionStream.next()

API Reference

createTransactionStream(options?)

Creates a new transaction stream instance.

Options

| Option | Type | Default | Description | | ---------------------- | --------------------------------------------------- | -------------------------------------------- | ------------------------------------------- | | gatewayApi | RadixNetworkClient | createRadixNetworkClient({ networkId: 1 }) | The Radix network client to use | | startStateVersion | number | Current state version | The state version to start streaming from | | numberOfTransactions | number | 100 | Number of transactions to fetch per request | | debug | boolean | false | Enable debug logging | | logLevel | 'debug' \| 'info' \| 'warn' \| 'error' \| 'trace' | 'debug' | Log level when debug is enabled |

Returns

A transaction stream object with the following methods:

  • next(): Fetches the next batch of transactions
  • setStateVersion(version: number): Manually set the current state version
  • getStateVersion(): Get the current state version

Transaction Result

The next() method returns a Result object (from the neverthrow library) that contains either:

Success Case

{
  stateVersion: number;
  transactions: Transaction[];
}

Where Transaction is a transaction object from the Radix Gateway API.

Error Case

Various error types with appropriate context information.

Error Handling

The transaction stream uses the neverthrow library for error handling, which means all operations return a Result type that must be checked.

Common errors include:

  • StateVersionBeyondEndOfKnownLedger: Occurs when trying to fetch transactions beyond the current ledger state
  • Network errors
  • Gateway API errors

License

MIT