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/...',
]))

# or

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

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

MultiProvider

This provider keeps track of the current endpoint and switches to the next one if an error occurs. It fails if no endpoints are available.

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-2.0.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

web3_multi_provider-2.0.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file web3_multi_provider-2.0.0.tar.gz.

File metadata

  • Download URL: web3_multi_provider-2.0.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.1 Linux/6.5.0-1025-azure

File hashes

Hashes for web3_multi_provider-2.0.0.tar.gz
Algorithm Hash digest
SHA256 6b8aa6d04363e941015ecec690cacca172d16d7d1c2da79d9ce224580db33eca
MD5 690b565dade1aa0038b46c8619f0436b
BLAKE2b-256 f41ba926176cf668ae89dfee796e51bd0684325104592c3cbeb39ed80ae301b7

See more details on using hashes here.

File details

Details for the file web3_multi_provider-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for web3_multi_provider-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f318015aa35ac3f768a011f68e32b208a203f28dff76afda832b67bb22b36e01
MD5 94b3ec17c3cb4486f1584bd1819eada4
BLAKE2b-256 519b41300f25a92337743e461b633d136f7dbc9e5e2e82fc238628d0703e763c

See more details on using hashes here.

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