Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
src
.gitignore
README.md
build.gradle.kts

README.md

What is it?

This module provides support for the Ethereum Name Service (ENS). For this it uses several other ENS-related KEthereum modules modules (e.g. EIP137 to generate the NameHash or ERC634 to access text records).

How to use it?

The only mandatory constructor parameter is the rpc that is used to connect to the Ethereum chain. By default the contract at 0x314159265dd8dbb310642f98f50c066173c1259b on them main chain will be used. So make sure your RPC is on the same chain.

val ens = ENS(rpc)

If you want to use another contract you can pass it in like this:

val ens = ENS(rpc ,Address("0x112234455c3a32fd11230c42e7bccd4a84e02010"))

to use the contract deployed on görli.

You can then resolve data. E.g. to get the Ethereum address associated with some ens name you can do:

val address = ens.getAddress(ENSName("vitalik.eth"))

Be aware that ens domains do not need to end in ".eth" - the following will also resolve:

val address = ens.getAddress(ENSName("kevins.xyz"))

If you want to find out if an ens name is a potential ENS domain (e.g. to prevent hitting your RPC with futile requests) you can use the following extension function:

val willBeTrue = ENSName("test.eth").isPotentialENSDomain()
val willBeFalse = ENSName("test.yo").isPotentialENSDomain()

To get the github username for a name you can do:

val address = ens.getGithubUserName(ENSName("ligi.ethereum.eth"))

If you want to do a reverse lookup you can do:

val name = ens.reverseResolve(Address("d8da6bf26964af9d7eed9e03e53415d37aa96045"))```
You can’t perform that action at this time.