Skip to main content

Web3py provider that makes it easy to switch between different blockchain nodes to make sure application will be be online if main blockchain node will be unavailable.

Project description

Lido Web3 Multi Provider

Code style: black License: MIT

Provider that accepts multiple endpoints.

Install

$ pip install web3-multi-provider

or

$ poetry add web3-multi-provider

Usage

from web3 import Web3
from web3_multi_provider import MultiProvider
from web3_multi_provider import FallbackProvider

w3 = Web3(MultiProvider([  # RPC endpoints list
    'http://127.0.0.1:8000/',
    'https://mainnet.infura.io/v3/...',
    'wss://mainnet.infura.io/ws/v3/...',
]))

# or

w3 = Web3(FallbackProvider([  # RPC endpoints list
    'http://127.0.0.1:8000/',
    'https://mainnet.infura.io/v3/...',
    'wss://mainnet.infura.io/ws/v3/...',
]))

last_block = w3.eth.get_block('latest')

MultiProvider

This provider tracks currently used endpoint internally and switch to the next one on error or fails if no more endpoints to switch to.

FallbackProvider

This provider sends requests to the all endpoints in the sequence until response received or endpoints list exhausted.

For developers

  1. poetry install - to install deps
  2. pre-commit install - to install pre-commit hooks

Tests

poetry run pytest tests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

web3_multi_provider-0.6.0.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

web3_multi_provider-0.6.0-py3-none-any.whl (5.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page