Skip to main content

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
  • Works with Ethereum, Binance, Avalanche, Arbitrum One, zkSync Era, etc.
  • Subscribe to pending transactions in the mempool and new blocks
  • Flexible logging of RPC calls and transactions
  • Interact with tokens and ETH with the same dual interface
  • Includes a client for Compound V2 operations, and its clones
  • 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

  • Stream pending transactions on the zkSync Era network:

    from web3client.base_client import BaseClient
    
    client = BaseClient("wss://mainnet.era.zksync.io/ws")
    client.subscribe(lambda tx, _, __: print(f"Pending tx: {tx}"))
    
  • Send 1 ETH and 100 USDC to Unicef, using a dual client:

    from web3client.erc20_client import DualClient
    
    rpc = "https://cloudflare-eth.com"
    private_key = "0x..."
    unicef = "0xA59B29d7dbC9794d1e7f45123C48b2b8d0a34636"
    USDC = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
    
    usdc_client = DualClient(rpc, private_key=private_key, contract_address=USDC)
    usdc_client.send_eth(unicef, 1)
    usdc_client.transfer(unicef, 100)
    

More examples

Please find more examples

Test suite web3test

web3client comes with several pytest plugins you can use to test your scripts:

  • web3test-ape: fixtures of accounts and smart contracts (erc20, compound, etc)
  • web3test-web3client: fixtures of clients for various smart contracts
  • web3test-web3factory: fixtures of clients for various chains

To use one or more plugins in your script, add the following lines at the top of your `conftest.py``:

pytest_plugins = [
    "web3test-ape", "web3test-web3client", "web3test-web3factory"
]

The order of the plugins in the aray is important.

It doesn't work 😡

Don't panic! Instead...

  1. Please check if your issue is listed in the Issues tab.
  2. If not, consider writing a new issue 🙂

Contributing

All contributions are welcome! To start improving web3client, please refer to our contribution guide.

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

web3client-1.3.4.tar.gz (2.2 MB view details)

Uploaded Source

Built Distribution

web3client-1.3.4-py3-none-any.whl (2.7 MB view details)

Uploaded Python 3

File details

Details for the file web3client-1.3.4.tar.gz.

File metadata

  • Download URL: web3client-1.3.4.tar.gz
  • Upload date:
  • Size: 2.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.10.0 CPython/3.11.5

File hashes

Hashes for web3client-1.3.4.tar.gz
Algorithm Hash digest
SHA256 c7e72134653f0bcfefa3138781603cece3829e0f6f2490a0db765a1113d727a0
MD5 6746864277dafd9abdba95ff35522366
BLAKE2b-256 4a066a478c5c49c6fe0e632d76ed523b41e2a1738c0ff09342da104429fdc9b0

See more details on using hashes here.

File details

Details for the file web3client-1.3.4-py3-none-any.whl.

File metadata

  • Download URL: web3client-1.3.4-py3-none-any.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.10.0 CPython/3.11.5

File hashes

Hashes for web3client-1.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 814d780629b28b6710f272743563aa50746249a342c047f22fdf4f7d985be533
MD5 6f1c965c0c7bf67aa165fda75ce8ed43
BLAKE2b-256 16cbf4621de71b0299eaaea63b9f0c73c10e0ca8874839420f20b0a5d456e70b

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