web3.py v7 Release Announcement

The next big chapter of web3.py's development is here! The first stable version of web3.py v7.0.0 is available! This post will give you a quick tour of important features and breaking changes.

WebSocketProvider & AsyncIPCProvider

Another dedicated blog post provides the full intro and context, but much of the v7 investment is realized in the totally redesigned WebSocketProvider and newly introduced AsyncIPCProvider. Each includes proper support for eth_subscribe, enabling live subscriptions for on-chain events.

Middleware Makeover

The middleware architecture got a rewrite, replacing a functional programming pattern with a class-based one. Context and examples are captured in a dedicated blog post, but the TL;DR is that the new pattern grants greater control and flexibility of how the middleware gets utilized within web3.py, opening the door for new features, like batch requests.

Batch Requests

Now that the middleware architecture can properly handle it, batch requests are supported. To learn when and how to effectively use batch requests, consult the relevant section in the documentation.

Exception Handling

All exceptions thrown by web3.py now inherit from a Web3Exception class, making them easier to isolate. The same is true of more specific error types, e.g., web3.py will throw a Web3ValueError vs. a standard ValueError. Additional changes to error handling can be found here.

ABI Utility Methods Overhaul

web3.py v7 features a more extensive set of public utility methods for interacting with contract ABIs. Many of these previously internal methods were ported to the eth-utils dependency and re-exposed via the web3.utils.abi public API. Reach for these when you need to extract information about functions, events, or errors from a contract's ABI.

Docs Reorganization

V7 is accompanied by a restructuring of the docs. The aim is to still provide accessibility for newcomers, but give those who know what they're looking for a much more clear path to find it.

Additional Breaking Changes

You'll find the full list within the migration guide, but you can expect a number of notable breaking changes when upgrading from v6, including:

  • Middleware are now imported as the class, rather than an instantiated alias.
  • WebsocketProvider was renamed to LegacyWebSocketProvider.
  • WebsocketProviderV2 (beta) was renamed to WebSocketProvider (stable).
  • Remaining camelCase usage was converted to snake_case.

web3.py v6

With the stable v7 release, v6 version of the library has transitioned to maintenance mode. While bugs may be addressed, new feature requests will be considered for v7. Official support for v6 will sunset in six months.

The Road Ahead

In addition to keeping up with normal maintenance, our team has recently settled on three goals for the immediate future:

  1. Aid EIP implementation and testing. We've been busy hacking on an EELS back-end to plug into eth-tester, which we hope will soon open the door for EIP authors and researchers to gain significantly more confidence in their changes by testing them again a mature Ethereum JSON-RPC test suite.
  2. Reduce UX friction. The mentioned ABI utils in this release are a great example of the intention here. Contract and encode/decode utils up next.
  3. Educate and inspire builders. We're aiming to deliver a "zero to hackathon participant" workshop for Python developers at Devcon. Along the way, sneko and popupfaucet are open source Python projects being developed in support of that goal.

Feedback?

Help us along the path! Let us know how we're doing, where you experience UX friction, feature or content requests, and whatever else comes to mind. When you're done there, join the conversation on Discord! 🐍🖖