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

@smarttokenlabs/waterfall-rpc

v0.9.3

Published

A universal RPC provider with waterfall fallback mechanism for Ethereum networks

Readme

Waterfall RPC

npm version

A universal RPC provider with waterfall fallback mechanism for Ethereum networks. This library automatically fetches and manages RPC endpoints from Chainlist (https://github.com/DefiLlama/chainlist), providing a reliable way to interact with various Ethereum networks.

Features

  • Automatically fetches and caches RPC endpoints from Chainlist
  • Implements a waterfall fallback mechanism for reliable RPC access
  • Supports all Ethereum networks listed on Chainlist
  • Automatic RPC endpoint health checking
  • Weekly automatic updates of RPC endpoints
  • Built-in progress display during RPC validation
  • Customizable progress tracking

Installation

npm install @smarttokenlabs/waterfall-rpc

Usage

Basic Usage (with built-in progress display)

Display name of USDC

import { WaterfallRpc } from "@smarttokenlabs/waterfall-rpc";
import { ethers } from "ethers";

const erc20Abi = [
    "function balanceOf(address owner) view returns (uint256 balance)",
    "function name() view returns (string)"
];

const usdcAddress = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";

const start = async () => {
    const provider = await WaterfallRpc.createProvider(1);
    const contract = new ethers.Contract(usdcAddress, erc20Abi, provider);

    const usdcName = await contract.name();
    console.log('USDC Name:', usdcName);
};

start();

Get blocknumber for Base Sepolia

import { WaterfallRpc } from '@smarttokenlabs/waterfall-rpc';

// Create a provider for Base Sepolia (will show progress automatically)
const provider = await WaterfallRpc.createProvider(84532);

// Use the provider with ethers.js
const blockNumber = await provider.getBlockNumber();
console.log(`Current block number: ${blockNumber}`);

Custom Progress Display

Note: Only shown when the library runs for the first time (per chain). This validates the RPCs given in chainlist.org as some have gone dark.

import { WaterfallRpc, ProgressCallback } from '@smarttokenlabs/waterfall-rpc';

// Create a custom progress callback
const customProgress: ProgressCallback = (event) => {
    console.log(`Validating RPC ${event.current}/${event.total}: ${event.url}`);
    console.log(`Status: ${event.status}`);
};

// Create a provider with custom progress display
const provider = await WaterfallRpc.createProvider(84532, customProgress);

Disable Progress Display

import { WaterfallRpc } from '@smarttokenlabs/waterfall-rpc';

// Create a provider without progress display
const provider = await WaterfallRpc.createProvider(84532, () => {});

API Documentation

WaterfallRpc

The main class that provides a reliable RPC connection with fallback support.

Static Methods

  • createProvider(chainId: number, onProgress?: ProgressCallback): Promise<WaterfallRpc>
    • Creates a new provider instance for the specified chain ID
    • Automatically checks and filters working RPC endpoints
    • Shows a progress bar by default
    • Optional custom progress callback

Types

interface ProgressEvent {
    current: number;    // Current RPC being checked (1-based)
    total: number;      // Total number of RPCs to check
    url: string;        // URL of the RPC being checked
    status: 'checking' | 'success' | 'failed';  // Current status of the check
}

type ProgressCallback = (event: ProgressEvent) => void;

Instance Methods

  • All standard ethers.js provider methods are available
  • The provider automatically handles RPC failures and retries with different endpoints

License

MIT