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
Web3 Multi Provider
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
poetry install
- to install depspre-commit install
- to install pre-commit hooks
Tests
poetry run pytest tests
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b8aa6d04363e941015ecec690cacca172d16d7d1c2da79d9ce224580db33eca |
|
MD5 | 690b565dade1aa0038b46c8619f0436b |
|
BLAKE2b-256 | f41ba926176cf668ae89dfee796e51bd0684325104592c3cbeb39ed80ae301b7 |
File details
Details for the file web3_multi_provider-2.0.0-py3-none-any.whl
.
File metadata
- Download URL: web3_multi_provider-2.0.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.1 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f318015aa35ac3f768a011f68e32b208a203f28dff76afda832b67bb22b36e01 |
|
MD5 | 94b3ec17c3cb4486f1584bd1819eada4 |
|
BLAKE2b-256 | 519b41300f25a92337743e461b633d136f7dbc9e5e2e82fc238628d0703e763c |