The first beta release of web3 v5 is out! Below you’ll find a high-level list of new features and backwards incompatible changes. The v5 migration guide gives a lower level overview to migrate your code, and you can look at the release notes for the complete list of changes.

How to Install

If you’re ready to get started with v5 now, you can install with pip. Pip won’t install beta versions by default, so use the --pre flag to get it now:

pip install --pre web3

Python 3.5 Support Dropped

In v5, Python 3.5 is no longer supported. You’ll need to have Python 3.6+ installed.

JSON-RPC Endpoint Updates

In v4, JSON-RPC calls that looked up transactions or blocks and didn’t find them returned None . In v5, if a transaction or block is not found, either a BlockNotFound error or a TransactionNotFound error will be thrown as applicable. For example: web3.eth.getTransaction(‘not-a-transaction-hash’) now throws a TransactionNotFound error. These exceptions can be imported from web3.exceptions if you need to catch them in your code.

JSON-RPC endpoints have been standardized to align with EIP-1474.

We removed JSON-RPC endpoints from the global namespace if only a certain client supports them. For instance, Geth is the only client that implements the Admin API. So, all of the JSON-RPC endpoints that used to be found at web3.admin.<method name> are now available at web3.geth.admin.<method name> . Same with the Miner API: all endpoints that used to be available at web3.miner.<method name> are now located at web3.geth.miner.<method name> . Similarly, we’ve moved the Personal API RPC endpoints to reflect the Geth and Parity implementations.

Additionally, there were a couple JSON-RPC endpoints that were duplicates and removed:

- web3.mining.hashrate was removed because it was a duplicate of web3.eth.hashrate

- web3.version.network was removed because it was a duplicate of web3.net.version

Check out the v5 migration guide for a full list of methods that have been changed.

Providers

We’ve moved to allow only a single provider in v5. While allowing multiple providers is a feature we’d like to support in the future, the way that multiple providers was handled in v4 wasn’t ideal. The only thing they could do was fall back. There was no mechanism for round robin, nor was there any control around which provider was chosen. Eventually, we’d like to expand the Manager API to support injecting custom logic into the provider selection process.

We’ve also changed the IPCProvider so that it no longer automatically looks up a testnet connection. If you want to use a testnet, you’ll need to pass in the path.

ENS

Web3py has stopped inferring the .eth TLD on domain names. If a domain name is used instead of an address, you’ll need to specify the TLD. An InvalidTLD error will be thrown if the TLD is missing.

Deprecated Methods on Contract

There are some methods that used to be available on a contract instance that are deprecated in v4. We’ve removed them in v5:

Deprecated Web3 methods

Web3.sha3 has been renamed to the more accurate Web3.keccak . Similarly, Web3.soliditySha3 has been renamed to Web3.solidityKeccak .

New Features

Infura

We’ve added 3 new Infura networks. You can now connect to Rinkeby, Kovan, and Goerli via:

from web3.auto.infura.rinkeby import w3

from web3.auto.infura.kovan import w3

from web3.auto.infura.goerli import w3

In March, Infura started requiring API keys to access any of their networks, so if you’re using Infura, you’ll need to have the WEB3_INFURA_PROJECT_ID environment variable set. Infura also added the option to require a secret key to interact with your projects. If your projects requiresa a secret key, the WEB3_INFURA_SECRET_KEY environment variable will also need to be set.

ContractCaller API

Because there was so much confusion around the ConciseContract and ImplicitContract classes, we have chosen to deprecate those interfaces. However, we still think there is value in the concise style. We’ve implemented a new API for reading from contracts. With v5, you can read from a contract using: contract.caller.<function name> .

For example, if I had a simple contract deployed that looks like this:

contract Greeter {

function greet() public pure returns (string) {

return ‘Hello’;

}

}

I could say:

>>> contract.caller.greet()

'Hello'

or

>>> contract.caller().greet()

'Hello'

A transaction dictionary can be passed in as well. You’d use:

>>> contract.caller({transaction_dict}).greet()

or the transaction keyword:

>>> contract.caller(transaction={transaction_dict}).greet()

block_identifier is a supported keyword argument as well. For example:

>>> contract.caller(block_identifier=‘latest’).greet()

Package Manager

EthPM is now available in web3py! Easily install and deploy smart contracts from your favorite package registries. To learn more about EthPM visit www.ethpm.com or read the web3.pm documentation. Note that the package management API is currently experimental, and likely to change in future web3py releases.

And More Coming Soon!

There are also some features that are backwards compatible that will be available in future v5 releases! This list includes async functionality, accessing JSON-RPC methods using snake case instead of camel case, and type hinting.