{"id":50841067,"url":"https://github.com/tetherto/wdk-failover-provider","last_synced_at":"2026-06-14T06:35:27.529Z","repository":{"id":352066138,"uuid":"1143245308","full_name":"tetherto/wdk-failover-provider","owner":"tetherto","description":null,"archived":false,"fork":false,"pushed_at":"2026-05-07T12:56:37.000Z","size":154,"stargazers_count":0,"open_issues_count":2,"forks_count":5,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-07T14:47:46.759Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tetherto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-27T10:44:16.000Z","updated_at":"2026-05-07T12:56:41.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/tetherto/wdk-failover-provider","commit_stats":null,"previous_names":["tetherto/wdk-failover-provider"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/tetherto/wdk-failover-provider","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tetherto%2Fwdk-failover-provider","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tetherto%2Fwdk-failover-provider/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tetherto%2Fwdk-failover-provider/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tetherto%2Fwdk-failover-provider/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tetherto","download_url":"https://codeload.github.com/tetherto/wdk-failover-provider/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tetherto%2Fwdk-failover-provider/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34312072,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-14T02:00:07.365Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-14T06:35:26.909Z","updated_at":"2026-06-14T06:35:27.523Z","avatar_url":"https://github.com/tetherto.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WDK Failover Provider\n\nZero-dependency failover mechanism for seamless fallback when providers break.\n\n## 🔍 About WDK\n\nThis module is part of the [**WDK (Wallet Development Kit)**](https://wallet.tether.io/) project, which empowers developers to build secure, non-custodial wallets with unified blockchain access, stateless architecture, and complete user control.\n\nFor detailed documentation about the complete WDK ecosystem, visit [docs.wallet.tether.io](https://docs.wallet.tether.io).\n\n## ⬇️ Installation\n\n```bash\nnpm install @tetherto/wdk-failover-provider\n```\n\n## 🚀 Quick Start\n\n```ts\nimport FailoverProvider from '@tetherto/wdk-failover-provider'\nimport { type AbstractProvider, JsonRpcProvider, BrowserProvider } from 'ethers'\n\nconst RPC_PROVIDER = 'https://mainnet.infura.io/v3/YOUR_INFURA_KEY'\n\n// Create a failover provider that will try the BrowserProvider first,\n// then fallback to a JSON-RPC provider on errors.\nconst provider = new FailoverProvider\u003cAbstractProvider\u003e()\n  .addProvider(new BrowserProvider(window.ethereum))\n  .addProvider(new JsonRpcProvider(RPC_PROVIDER))\n  .initialize()\n\n// Calls are proxied and will failover according to the configured retries\n;(async () =\u003e {\n  const blockNumber = await provider.getBlockNumber()\n  console.log('block number', blockNumber)\n})()\n```\n\n## 📚 API Reference\n\nThis package exposes a single default export: the `FailoverProvider` factory.\n\n- `new FailoverProvider(config?)` — Create a factory.\n  - `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.\n  - `config.shouldRetryOn` (function, default: `error =\u003e error instanceof Error`): predicate to determine whether to retry on a given error.\n\n- `instance.addProvider(provider)` — Add a provider candidate. `provider` can be any object (sync or async methods).\n\n- `instance.initialize()` — Return a proxied provider. Calls to methods are intercepted and automatically retried/failover according to the configuration.\n\nBehavior notes:\n\n- The returned proxied provider forwards non-function properties from the currently active provider.\n- When a method throws exceptions and `shouldRetryOn(error)` returns `true`, the proxy switches to the next provider (round-robin) and retries until retries are exhausted.\n\n## 📜 License\n\nThis project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.\n\n## 🤝 Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## 🆘 Support\n\nFor support, please open an issue on the GitHub repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftetherto%2Fwdk-failover-provider","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftetherto%2Fwdk-failover-provider","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftetherto%2Fwdk-failover-provider/lists"}