ENS names are now the best way to use Web3.py

Goodbye hex addresses; we won’t miss you

It is error prone and cumbersome to enter long hexadecimal strings into fields. But many people have no other choice when sending ether, or interacting with contracts. This needs to stop.

You don’t type “” into your browser.
So why are you still sending ether like this? “0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359”

The good news is that the solution is already launched*: the Ethereum Name Service (ENS). Using it, anyone can cheaply claim a name to point to an Ethereum address. There is no reason that any trustworthy Ethereum app should ask you to interact with a hex address. Every one of them should give you a “.eth” name instead.

So why do some Eth apps still distribute hex addresses?

Providing an ENS name is not yet a universal practice among Eth apps, even among ICOs that have so much at stake. The primary issue is that many tools are not integrated with ENS. That’s starting to change, but even incredibly popular tools like web3.js do not have native integration yet. If you are a maintainer of any Ethereum tool that interacts with addresses, ENS support should be at the top of your list. Web3.py is a prime example of a tool that interacts with addresses a lot. It also did not have ENS support, until today.

ENS is natively supported throughout Web3.py

If you are connecting to the production Ethereum network, ENS lookups now work in Web3.py without any special configuration. Note that you need to install the v4 beta to activate this feature:

$ pip install --pre web3

The old way of sending a transaction was:

from web3 import Web3, IPCProvider
w3 = Web3(IPCProvider())
'from': '0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413',
'to': '0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359',

In v4, you can use a much friendlier call:

from web3.auto import w3
'from': 'enigma.party.eth',
'to': 'ethereumfoundation.eth',

You can use an ENS name anywhere in Web3.py that you would normally use a hex address. Do you want read from a contract? Specify the contract address using a .eth name. Do you want to send an address as an argument to a contract function? Use an ENS name in its place. Et cetera.

Please give it a try and tell us what you think! We actively monitor github issues and gitter.

*For domains under “.eth”, only names of 7 characters or more are available. Shorter names will be available in 2019.