Ethereum Name Service¶
The Ethereum Name Service (ENS) provides a human readable names to identify addresses on the Ethereum network. It is similar to the internet's domain name service (DNS) which provides human-readable domain names which are mapped to IP addresses.
In the case of ENS, the addresses are either wallet or smart contract addresses.
E.g. instead of using the wallet address
0x19e03255f667bdfd50a32722df860b1eeaf4d635, you can use
Usage in web3j¶
You can use ENS names anywhere you wish to transact in web3j. In practice this means, in smart contract wrappers, when you load them, such as:
YourSmartContract contract = YourSmartContract.load( "0x<address>|<ensName>", web3j, credentials, GAS_PRICE, GAS_LIMIT);
Also, when performing Ether transfers, such as using the command line tools:
$ web3j wallet send <walletfile> 0x<address>|<ensName>
The resolution process is as follows:
- Check to see if our Ethereum node is fully synced
- If not fail
If it is synced, check the timestamp on the most recent block it has.
- If it's more than 3 minutes old, fail.
- Otherwise perform the lookup
If you need to change the threshold parameter of what constitutes being synced to something other then 3 minutes, this can be done via the
setSyncThreshold method in the ManagedTransaction class.
Unicode Technical Standard (UTS) #46¶
UTS #46 is the standard used to sanitise input on domain names. The web3j ENS implementation performs this sanitation on all inputs before attempting resolution. For details of the implementation, refer to the NameHash class.
Registering domain names¶
Currently, web3j only supports the resolution of ENS domains. It does not support the registration. For instructions on how to do this, refer to the ENS documentation.