Batteries-included client to interact with blockchains and smart contracts
Project description
Batteries-included client to interact with blockchains and smart contracts; used by web3cli
and crabada.py.
Features
- Easily create a client to interact with EVM-compatible chains
- Interact with the most popular chains: Ethereum, Binance, Avalanche, Arbitrum One, zkSync Era, and more to come!
- Includes a client for Compound V2 operations, and its clones
- Subscribe to pending transactions in the mempool and new blocks.
- Save gas by setting an upper limit on the base fee.
- Need more flexibility? Use directly the underlying web3.py client.
Install
pip3 install -U web3client
Examples
Get the latest block on supported blockchains:
from web3factory.factory import make_client
eth_block = make_client("eth").get_latest_block() # Ethereum
bnb_block = make_client("bnb").get_latest_block() # BNB chain
avax_block = make_client("avax").get_latest_block() # Avalanche
arb_block = make_client("arb").get_latest_block() # Arbitrum
era_block = make_client("era").get_latest_block() # zkSync Era
Get the ETH and USDC balances of the Ethereum foundation:
from web3factory.factory import make_client, make_erc20_client
address = "0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae"
eth = make_client("eth").get_balance_in_eth(address)
usdc = make_erc20_client("USDC", "eth").balanceOf(address) / 10**6
Get the BNB and BUSD balances of Binance's hot wallet:
from web3factory.factory import make_client, make_erc20_client
address = "0x8894e0a0c962cb723c1976a4421c95949be2d4e3"
bnb = make_client("bnb").get_balance_in_eth(address)
busd = make_erc20_client("BUSD", "bnb").balanceOf(address) / 10**18
More examples
Please have a look at the tests folder or at the examples folder 🙂
Custom chains & contracts
The factory module only allows to interact with a small list of chains and contracts.
To interact with an arbitrary EVM chain or smart contract, instantiate a custom
client using the BaseClient
class.
For a more structured approach, use web3core
, a sub-package
of web3cli
that comes with many preloaded chains, and allows
to import chains and smart contracts dynamically.
It doesn't work 😡
Don't panic! Instead...
- Please check if your issue is listed in the Issues tab.
- If not, consider writing a new issue 🙂
Contributing
All contributions are welcome! To start improving web3client
, please refer to our contribution guide.
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 web3client-1.2.1.tar.gz
.
File metadata
- Download URL: web3client-1.2.1.tar.gz
- Upload date:
- Size: 644.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.8.1 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9210345e90c89c235a6f82768cecca06931ab9117c172678daf3b3d348fc7dce |
|
MD5 | 2713a2a8517ed2cbbda4ac30f319e02b |
|
BLAKE2b-256 | 406b2c7a34f138fe764196c55ef9c73e3aa2b8841a0071378fcf2cf659459266 |
File details
Details for the file web3client-1.2.1-py3-none-any.whl
.
File metadata
- Download URL: web3client-1.2.1-py3-none-any.whl
- Upload date:
- Size: 29.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.8.1 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6dba6e019f5c712e064d17539643a82734ec82745515822fd5ea2c0d9f46e36 |
|
MD5 | 95c1905a9119e33e266320a0e0914dc4 |
|
BLAKE2b-256 | 0622e8632a42e1d511603f4ef13c12c749398c8bb83df0dd737818d56c9763c1 |