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

Uploaded Source

Built Distribution

web3_multi_provider-1.0.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: web3_multi_provider-1.0.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.2 Linux/6.5.0-1024-azure

File hashes

Hashes for web3_multi_provider-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3164330894b0baeae701d75b6c30210fdaa9db7edb6d07593e062c949887a0db
MD5 24ad42a300375604cbdadb57464ee5f3
BLAKE2b-256 4d6dcbdeeca0e10f571465e8c703427c28616fb4cc34de24d9f1bb2414cf0a82

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web3_multi_provider-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0b59256ad3d738328110259cf9c6779ec5be51abe6f01f3d76f115e06254183e
MD5 85f84ff500bbea4fe93c7ae03cf8a901
BLAKE2b-256 4cf9a1064f327f49b7415bde43e233b7786f48f963160390b4f10aa2e238aab2

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