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

@tetherto/wdk-failover-provider

v1.0.0-beta.5

Published

Provider failover utilities for WDK (Wallet Development Kit) by Tether.

Readme

WDK Failover Provider

Zero-dependency failover mechanism for seamless fallback when providers break.

🔍 About WDK

This module is part of WDK (Wallet Development Kit) by Tether, which empowers developers to build secure, non-custodial wallets with unified blockchain access, stateless architecture, and complete user control.

See the Failover Provider documentation. For the complete ecosystem, see the general WDK documentation.

⬇️ Installation

npm install @tetherto/wdk-failover-provider

🚀 Quick Start

import FailoverProvider from '@tetherto/wdk-failover-provider'
import { type AbstractProvider, JsonRpcProvider, BrowserProvider } from 'ethers'

const RPC_PROVIDER = 'https://mainnet.infura.io/v3/YOUR_INFURA_KEY'

// Create a failover provider that will try the BrowserProvider first,
// then fallback to a JSON-RPC provider on errors.
const provider = new FailoverProvider<AbstractProvider>()
  .addProvider(new BrowserProvider(window.ethereum))
  .addProvider(new JsonRpcProvider(RPC_PROVIDER))
  .initialize()

// Calls are proxied and will failover according to the configured retries
;(async () => {
  const blockNumber = await provider.getBlockNumber()
  console.log('block number', blockNumber)
})()

📚 API Reference

This package exposes a single default export: the FailoverProvider factory.

  • new FailoverProvider(config?) — Create a factory.

    • config.retries (number, default 3): The number of additional retry attempts after the initial call fails. Total attempts = 1 + retries. For example, retries: 3 with 4 providers will try each provider once before throwing. If retries exceeds the number of providers, the failover will loop back and retry already-failed providers in round-robin order.
    • config.shouldRetryOn (function, default: error => error instanceof Error): predicate to determine whether to retry on a given error. The second argument, context, describes the failed call: context.method is the property or method name, and context.args holds the call arguments (undefined when reading a property failed). Use it to treat non-idempotent calls differently: replay a transaction broadcast only when the error proves the request never reached the provider (for example a refused connection or a 4xx returned before processing), and never on timeouts or on errors returned after the provider may have accepted it, so the original error reaches the caller.
  • instance.addProvider(provider) — Add a provider candidate. provider can be any object (sync or async methods).

  • instance.initialize() — Return a proxied provider. Calls to methods are intercepted and automatically retried/failover according to the configuration.

Behavior notes:

  • The returned proxied provider forwards non-function properties from the currently active provider.
  • When a method throws exceptions and shouldRetryOn(error, context) returns true, the proxy switches to the next provider (round-robin) and retries until retries are exhausted.

📜 License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

🆘 Support

For support, please open an issue on the GitHub repository.