web3-rpc-failover

web3 rpc provider connectivity failover

MIT License

Downloads
10
Stars
4

web3-rpc-failover

FailoverProvider via yaml configuration file for cascading connection fallbacks

Motivation

Providing assurances for Service Provider outages in a robust and simple way.

Do not confuse our usage of failover with how ethers-js uses fallback. see the ethers documentation, fallback provider

Install

npm i web3-rpc-failover

Usage: as an external module

  • install web3-rpc-failover

  • configure your RPC Service Providers in order of preference for failover

    providers:
      - url: 'https://mainnet.infura**'
        config:
          priority: 2
          stallTimeout: 200
          weight: 2
      - url: 'infura.io/zzz'
        config:
          priority: 1
          stallTimeout: 100
          weight: 1
    

    priority: priority used for the provider stallTimeout: timeout (in ms)

Usage: as a library

const {FallbackProvider} = require('web3-rpc-failover')
const provider = new FallbackProvider(<pathToYAMLConfig>)

License

MIT