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.
Examples
Get the latest block on both Ethereum, BNB Chain and Avalanche:
from web3factory.factory import make_client
eth_block = make_client('ethereum').getLatestBlock()
bnb_block = make_client('binance').getLatestBlock()
avax_block = make_client('avalanche').getLatestBlock()
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").getBalanceInEth(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").getBalanceInEth(address)
busd = make_erc20_client("BUSD", "binance").balanceOf(address) / 10**18
More examples
Please have a look at the examples folder 🙂
Install
pip3 install -U web3client
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 🙂
Contribute ❤️
Pull requests are welcome!
- Install and configure PDM:
curl -sSL https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py | python3 -
- Install dependencies:
pdm install
- To run the CLI against your changes:
pdm web3client
- To run tests:
pdm test
TO DO
- Test ERC20 read functions
- Automatically convert addresses to checksum
- Harmonize between camel case and snake case
- Easy accessors for token and network props
- Add write examples and tests
- Add Uniswap V2 LP contracts
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
web3client-0.5.1.tar.gz
(15.2 kB
view hashes)
Built Distribution
web3client-0.5.1-py3-none-any.whl
(16.4 kB
view hashes)
Close
Hashes for web3client-0.5.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d401fb91415734c72769a8cc9c5615ea05df6c3f17ccb2e999fecbe17c84f8cf |
|
MD5 | 004149ba8cc62a10883314a2244a67c5 |
|
BLAKE2b-256 | 8b8e9086977cc53b0334324f07e367ce18a3ce876cecf0bea7b7d7c807a8d674 |