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

@railgun-community/waku-broadcaster-client-node

v9.0.1

Published

The **Node.js** specific package for the RAILGUN Broadcaster Client. This package is designed to run in server-side environments, scripts, or bots that need to interact with the RAILGUN privacy network via Waku.

Readme

RAILGUN Broadcaster Client (Node.js)

The Node.js specific package for the RAILGUN Broadcaster Client. This package is designed to run in server-side environments, scripts, or bots that need to interact with the RAILGUN privacy network via Waku.

Installation

yarn add @railgun-community/waku-broadcaster-client-node
# or
npm install @railgun-community/waku-broadcaster-client-node

Usage

1. Initialization

Initialize the client to connect to the Waku network.

import { WakuBroadcasterClient } from '@railgun-community/waku-broadcaster-client-node';
import { Chain } from '@railgun-community/shared-models';

const chain: Chain = { type: 0, id: 1 }; // Ethereum Mainnet

const broadcasterOptions = {
  // Required: Trusted Fee Signer
  trustedFeeSigner: '0zk1...', 
  // Optional: Waku options
  pubSubTopic: '/waku/2/default-waku/proto', 
  feeExpirationTimeout: 30000, // 30 seconds
  peerDiscoveryTimeout: 10000, // 10 seconds
  additionalDirectPeers: [], // Optional: Direct peers to connect to
  poiActiveListKeys: [], // Optional: POI keys
  useDNSDiscovery: false, // Optional: Use DNS discovery
  useCustomDNS: { // Optional: Custom DNS config
    onlyCustom: false,
    enrTreePeers: []
  },
  broadcasterVersionRange: { // Optional: Broadcaster version range
    minVersion: '8.0.0',
    maxVersion: '8.999.0'
  }
};

const statusCallback = (status: BroadcasterConnectionStatus) => {
  console.log('Connection status:', status);
};

await WakuBroadcasterClient.start(chain, broadcasterOptions, statusCallback);
console.log('Waku Broadcaster Client started');

2. Finding a Broadcaster

Once started, the client listens for fee updates from Broadcasters. You can query for the best broadcaster for a specific token.

import { Chain } from '@railgun-community/shared-models';

const chain: Chain = { type: 0, id: 1 }; // Ethereum Mainnet
const tokenAddress = '0x6b175474e89094c44da98b954eedeac495271d0f'; // DAI

// Wait a few seconds for peer discovery and fee updates...
await new Promise(r => setTimeout(r, 5000));

const selectedBroadcaster = await WakuBroadcasterClient.findBestBroadcaster(
  chain,
  tokenAddress
);

if (selectedBroadcaster) {
  console.log('Found broadcaster:', selectedBroadcaster.railgunAddress);
  console.log('Fee per unit gas:', selectedBroadcaster.feePerUnitGas);
} else {
  console.log('No broadcaster found for this token');
}

3. Sending a Transaction

Create a transaction and send it through the selected broadcaster.

import { BroadcasterTransaction } from '@railgun-community/waku-broadcaster-client-node';
import { TXIDVersion } from '@railgun-community/shared-models';

// ... (Assume you have a railgunWallet and transactionRequest)

const txidVersion = TXIDVersion.V2_PoseidonMerkle; // or V3
const to = '0x...'; // Destination address
const data = '0x...'; // Transaction data
const nullifiers = ['0x...']; // Nullifiers
const overallBatchMinGasPrice = 1000000000n; // Min gas price
const useRelayAdapt = false; // Whether to use Relay Adapt
const preTransactionPOIs = {}; // POIs

const broadcasterTransaction = await BroadcasterTransaction.create(
  txidVersion,
  to,
  data,
  selectedBroadcaster.railgunAddress,
  selectedBroadcaster.feesID,
  chain,
  nullifiers,
  overallBatchMinGasPrice,
  useRelayAdapt,
  preTransactionPOIs
);

try {
  const response = await BroadcasterTransaction.send(broadcasterTransaction);
  console.log('Transaction submitted. Tx Hash:', response.txHash);
} catch (error) {
  console.error('Failed to send transaction:', error);
}

Configuration

The start method accepts a BroadcasterOptions object.

  • trustedFeeSigner: (Required) The public key of the trusted fee signer.
  • poiActiveListKeys: (Optional) List of active POI list keys.
  • pubSubTopic: (Optional) The Waku pubsub topic to subscribe to. Defaults to the RAILGUN topic.
  • additionalDirectPeers: (Optional) Array of multiaddrs for direct peer connections.
  • peerDiscoveryTimeout: (Optional) Timeout in milliseconds for peer discovery.
  • feeExpirationTimeout: (Optional) Timeout in milliseconds for fee expiration.
  • useDNSDiscovery: (Optional) Boolean to enable DNS peer discovery.
  • useCustomDNS: (Optional) Configuration for custom DNS discovery.
    • onlyCustom: (Boolean) If true, only use the provided enrTreePeers.
    • enrTreePeers: (Array) List of ENR tree URLs.
  • broadcasterVersionRange: (Optional) Object specifying the allowed broadcaster version range.
    • minVersion: (String) Minimum allowed version.
    • maxVersion: (String) Maximum allowed version.

Dependencies

This package relies on:

  • @waku/sdk: For Waku networking.
  • @waku/discovery: For peer discovery.
  • @libp2p/tcp: For TCP transport (Node.js specific).

License

MIT