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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: web3-collections-0.0.2.tar.gz
  • Upload date:
  • Size: 3.7 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.2.tar.gz
Algorithm Hash digest
SHA256 143d60a515b833223ae5a4587d5d6af03035cdfef728d8bcee4885bb00a74c6f
MD5 5114748f979dc9ecd92ac2e2c27c5af1
BLAKE2b-256 25352673a24273429e6e7ff3fb5965dfa9bbd53dc6e45e858332a943868d6c8d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web3_collections-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dfbdd7ac180c4f66e2ed115c0e457bf26434f44f44651219b481f04dc3100516
MD5 1887481f6ba71f95a353d8d8925f0195
BLAKE2b-256 91c77f1eca5ff1a02ac739a4d83c911654e09bdf1d0703e38ffa24a6553bc05c

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