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
- Perform ERC20 operations, using the token name (e.g. USDC) instead of address.
- Interact with the most popular chains: Ethereum, Binance, Avalanche and more to come!
- 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 both Ethereum, BNB Chain and Avalanche:
from web3factory.factory import make_client
eth_block = make_client('ethereum').get_latest_block()
bnb_block = make_client('binance').get_latest_block()
avax_block = make_client('avalanche').get_latest_block()
Get the ETH and USDC balances of the Ethereum foundation:
from web3factory.factory import make_client, make_erc20_client
address = "0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae"
eth = make_client("ethereum").get_balance_in_eth(address)
usdc = make_erc20_client("USDC", "ethereum").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("binance").get_balance_in_eth(address)
busd = make_erc20_client("BUSD", "binance").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
Hashes for web3client-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dcc28beb9a2cba66ea05c24d6404a8e2fbb239624ba2e9eadcc52ad243754994 |
|
MD5 | 017d61087f6ce75733aa50a388f3f1e1 |
|
BLAKE2b-256 | 833fd7af5b6e57d8adf4ae77f0631657c1dc96841d2fbfa90bd5c90ee06be96d |