ENS Resolution

ENS, or Ethereum Name Service, is a distributed, open, and extensible naming system based on the Ethereum blockchain. ENS allows to map human-readable names like vitalik.eth to machine-readable identifiers such as Ethereum addresses, other cryptocurrency addresses, content hashes, and metadata (similar to DNS).

Mnemonic’s ENS resolution capabilities ensure builders can provide this experience to their users without the extra legwork of interacting with ENS to do reverse and forward lookups.

Mnemonic tracks any changes to the ENS domains and resolution of the domains to the corresponding addresses as it happens on the blockchain in order to provide the most up to date information.

In this tutorial, we’ll explore Mnemonic’s ENS forward lookup capabilities. You’ll learn how to resolve Ethereum wallet addresses (and mapping details) from an ENS domain with just a single API call. Let’s jump in!

ENS entities for a list of ENS domains

Mnemonic’s Foundational API offers two dedicated endpoints for forward and reverse lookup of ENS handles and wallet addresses, GetEnsByName, and GetEnsByAddress. Both endpoints allow you to resolve ENS handles or wallet addresses with ease.

In this tutorial, we want to retrieve the wallet address of an ENS domain (forward lookup) as such, we will use the GetEnsByName endpoint.

It requires only a single parameter: an ENS domain represented as a string.

Here is our query:

curl -i -X GET \
  'https://ethereum-rest.api.mnemonichq.com/wallets/v1beta2/ens/by_name/vitalik.eth' \
  -H 'X-API-Key: YOUR_API_KEY_HERE'

Our result will contain the following:

  • ENS Name: Human readable string of the ENS name you’ve resolved
  • Wallet Address: Resolved address of the given ENS name
  • Mapping Creation Time (Block Timestamp): The block timestamp where the last address was set for this ENS name
  • Expiration Time of the ENS Mapping: Expiration Time of the ENS domain name (if it exists)
  • Parent Domain: Resolved Domain name of the Parent node (if known) (for eg. Parent domain of vitalik.eth would be eth)

Note: DNS names that have an ENS record do not have any expiration time.

Here’s the results of our example request:

{
    "entity": {
        "name": "vitalik.eth",
        "resolvedAddress": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
        "validFromTimestamp": "2021-02-15T17:19:09Z",
        "validTillTimestamp": "2032-05-03T21:50:24Z",
        "parentName": "eth"
    }
}

Now you know how to conduct a forward lookup of an ENS domain and return its associated wallet address with ease. This capability makes it easy to enable your users to use their wallet addresses and ENS domains interchangeably within your application.

Wallet addresses for a list of ENS domains

Mnemonic’s Foundational API offers two dedicated endpoints for forward and reverse lookup of ENS handles and wallet addresses, GetEnsByName, and GetEnsByAddress. Both endpoints allow you to resolve ENS handles or wallet addresses and get details on ENS records with ease.

In this tutorial, we want to retrieve the associated ENS domain(s) for a given Ethereum wallet address (reverse lookup) as such, we will use the GetEnsByAddress endpoint.

It requires only a single parameter: an Ethereum wallet address represented as a string.

Here is our query:

curl -L -X GET \
    'https://ethereum-rest.api.mnemonichq.com/wallets/v1beta2/ens/by_address/0xd8da6bf26964af9d7eed9e03e53415d37aa96045' \
    -H 'X-API-Key: YOUR_API_KEY_HERE'

Our result will contain the following:

In addition to returning each of the associated ENS domains mapped to the wallet address you’re looking up, this query will retrieve the following details:

  • ENS Name: Human Readable string of the resolved (if known) ENS name
  • Mapping Creation Time (Block Timestamp):The block timestamp where the last address was set for this ENS name
  • Expiration Time of the ENS Mapping: Expiration Time of the ENS domain name (if it exists)
  • Parent Domain: Resolved Domain name of the Parent node (if known) (for eg. Parent domain of vitalik.eth would be eth)

Note: DNS names that have an ENS record do not have any expiration time.

Here’s the results of our example request:

{
    "entities": [
        {
            "name": "vitalik.eth",
            "resolvedAddress": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
            "validFromTimestamp": "2021-02-15T17:19:09Z",
            "validTillTimestamp": "2032-05-03T21:50:24Z",
            "parentName": "eth"
        },
        {
            "name": "vitalik.takoyaki.eth",
            "resolvedAddress": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
            "validFromTimestamp": "2019-12-26T02:08:27Z",
            "validTillTimestamp": null,
            "parentName": "takoyaki.eth"
        },
        {
            "name": "vbuterin.stateofus.eth",
            "resolvedAddress": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
            "validFromTimestamp": "2018-10-26T22:43:39Z",
            "validTillTimestamp": null,
            "parentName": "stateofus.eth"
        },
        {
            "name": "vitalik.cannafam.eth",
            "resolvedAddress": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
            "validFromTimestamp": "2022-07-23T04:40:23Z",
            "validTillTimestamp": null,
            "parentName": "cannafam.eth"
        },
        {
            "name": "7860000.eth",
            "resolvedAddress": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
            "validFromTimestamp": "2022-06-24T11:37:16Z",
            "validTillTimestamp": "2023-05-26T12:42:21Z",
            "parentName": "eth"
        }
    ]
}

Now you know how to conduct a reverse lookup of an ENS domain using its associated wallet address with ease. This capability makes it easy to enable your users to use their wallet addresses and ENS domains interchangeably within your application.

We love feedback here at Mnemonic! After you’ve completed this tutorial, let us know about your experience or share feedback by tagging us on Twitter @mnemonichq or reaching out directly to our [email protected]!