Skip to content

Fix Ethers Fallback Provider Errors

DodaTech Updated 2026-06-26 1 min read

You will learn how to configure FallbackProvider for high availability.

The Problem

The ethers provider fallback pattern is frequently misapplied in smart contract and dapp development, leading to vulnerabilities, gas inefficiencies, or logic errors. This guide shows the correct implementation and common pitfalls to avoid.

Quick Fix

Wrong

const provider = new ethers.providers.JsonRpcProvider(url); // Single point of failure

If the single node goes down, the app stops working.

const provider = new ethers.providers.FallbackProvider([
  new ethers.providers.JsonRpcProvider(url1),
  new ethers.providers.JsonRpcProvider(url2),
]);
Fallback switches between providers automatically. No downtime if one provider fails.

Prevention

  • Use FallbackProvider for production dapps
  • List providers by priority
  • Configure quorum for responses
  • Use DodaTech's provider benchmark
  • Monitor provider health regularly

DodaTech Tools

Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro. Doda Browser's developer tools include a Solidity debugger and transaction inspector. DodaZIP archives secure contract templates for team collaboration. Durga Antivirus Pro scans deployed contracts for known vulnerability signatures.

FAQ

### How does FallbackProvider handle failures?

It tries providers in order until one succeeds. Configure stallTimeout for slow providers.

What is quorum in FallbackProvider?

Number of provider responses needed for consensus. Higher quorum = more reliability but slower.

Can I set different weights for providers?

Yes. Each provider entry can have a weight. Higher weight = higher priority.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro