Skip to content

Design a resilient multi-chain RPC failover and wallet-connector fallback layer #341

Description

@Lakes41

Difficulty: Expert
Type: performance

Background
The app supports multiple chains (mainnet, base, sepolia) and configurable RPC URLs (NEXT_PUBLIC_WALLET_RPC_MAINNET, etc.) via lib/wallet/config.ts, with a currently single injected wallet connector, per the README's Environment Variables and Wallet Chains documentation.

Problem
As configured, each chain relies on a single RPC endpoint (whether the wagmi default or the configured browser-safe URL) with no fallback if that endpoint is slow, rate-limited, or down, and only one connector type is supported — if a member's injected wallet isn't available (mobile browser without an extension, etc.), there's no alternative connection path, hurting real-world reliability.

Expected outcome
lib/wallet/config.ts supports configuring multiple RPC endpoints per chain with automatic failover (and basic health-based deprioritization of a failing endpoint), and the wallet connector configuration is extended to support at least one additional connector type (e.g., WalletConnect) with graceful fallback/prompting when injected isn't available.

Suggested implementation

  • Extend the NEXT_PUBLIC_WALLET_RPC_* variables (or introduce comma-separated variants) to accept multiple URLs per chain, and use viem's fallback transport (fallback([...])) to compose them with retry/ranking behavior.
  • Add health tracking (e.g., recent failure count per endpoint) to deprioritize a consistently failing RPC without permanently blacklisting it (allow recovery).
  • Extend NEXT_PUBLIC_WALLET_CONNECTORS support beyond injected to include at least one additional wagmi connector, with the connect-button UI (components/wallet/connect-button.tsx) offering a fallback path when no injected wallet is detected.
  • Update lib/wallet/config.ts's validation (ConfigError) to cover the new multi-RPC and multi-connector configuration shapes.
  • Add tests simulating a failing primary RPC endpoint correctly falling back to a secondary, and simulating no injected wallet being present to verify the fallback connector path is offered.
  • Document all new configuration in .env.example and the README's Environment Variables table.

Acceptance criteria

  • Configuring multiple RPC URLs per chain results in automatic failover on primary failure
  • At least one non-injected wallet connector is supported and used as a documented fallback
  • Validation correctly rejects malformed multi-value configuration
  • Tests cover RPC failover and connector fallback scenarios
  • README/.env.example updated

Likely affected files/directories

  • lib/wallet/config.ts
  • lib/wallet/providers.tsx
  • components/wallet/connect-button.tsx
  • .env.example, README.md

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox Open Source Sponsorship program tagMaybe RewardedIssue may qualify for a reward upon successful completion per campaign rulesOfficial Campaign | FWC26Official FWC26 campaign issue — eligible for campaign scoring and rewardsexpertExpert difficulty tasks requiring deep expertise and architectural decision-makingperformancePerformance optimization or latency/throughput improvement work

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions