Skip to main content

Alternatives to some of the web3's classes

Project description

Web3.py collections

This module providing alternatives to some of the web3's classes

Installation

Install the package using the following command:

pip install -U web3-collections

Alternatives

Class name Alternative to
MultiEndpointHTTPProvider HTTPProvider

MultiEndpointHTTPProvider

The constructor gives a list of endpoint URIs. In each http request, it tries to use the current_endpoint to fetch data and if it fails, updates the current endpoint and tries again.

import web3
from web3_collections import MultiEndpointHTTPProvider

endpoint_uris = ['https://rpc.ankr.com/eth', 'https://1rpc.io/eth', 'https://eth.drpc.org', ...]
w3 = web3.Web3(MultiEndpointHTTPProvider(endpoint_uris))

By default auto_update=True and you don't need to use update_endpoint method. But, you can disable auto update and handle it manually:

w3 = web3.Web3(MultiEndpointHTTPProvider(endpoint_uris, auto_update=False))
try:
    w3.eth.get_block('latest')
except Exception as e:
    print(f'{w3.provider.current_endpoint} got error: {e}')
    w3.provider.update_endpoint()
    print(f'Endpoint updated to {w3.provider.current_endpoint}')

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-collections-0.0.3.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

web3_collections-0.0.3-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file web3-collections-0.0.3.tar.gz.

File metadata

  • Download URL: web3-collections-0.0.3.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.5

File hashes

Hashes for web3-collections-0.0.3.tar.gz
Algorithm Hash digest
SHA256 414d13cf3dbed10881863cb1667064265b075988ac44295bd43eb5b5cbf77942
MD5 34b5f919cf1048f19f8d97160fba25e3
BLAKE2b-256 75d6f71c5d1e19a1c86a2803915056abe2cdf9e671c7b1239534b62341582078

See more details on using hashes here.

File details

Details for the file web3_collections-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for web3_collections-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2a5099ad2d903231ae0b44ed6da224912e3df5cd16bc3ddc25489cb5230b8f32
MD5 8fbb19ac15781d1d7e1643573b131866
BLAKE2b-256 f83335e6f6113b856a9bb918870650188c319805368e5c4c2b04ea14e646e692

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