ENS (Ethereum Name Service) domains are a way to connect a human-readable domain (such as kian.eth) to an address on the Ethereum blockchain (such as 0x5295b474F3A0bB39418456c96D6FCf13901A4aA1).
This repo contains a Cloudflare Worker script that will perform the reverse-lookup: that is, given an ethereum address, return the ENS domain.
My address, which owns 2 ENS domains and has the reverse record set to 'kian.eth':
request: /ens/0x5295b474F3A0bB39418456c96D6FCf13901A4aA1
{
"reverseRecord": "kian.eth",
"domains": [
"kian.eth",
"бутерин.eth"
]
}
An address which owns 3 ENS but does not have a reverse record set:
request: /ens/0xd035a780deccf7808875c6a555937b7c44299f45
{
"reverseRecord": null,
"domains": [
"whiskey.dcl.eth",
"coins.dcl.eth",
"don.dcl.eth"
]
}
You can bypass the graphql call by setting ?mode=fast
in the request:
request: /ens/0x5295b474F3A0bB39418456c96D6FCf13901A4aA1?mode=fast
{
"reverseRecord": "kian.eth",
}
- Install cloudflare's 'wrangler' cli tool: https://developers.cloudflare.com/workers/cli-wrangler/install-update
- authenticate with cloudflare:
wrangler login
- open
wrangler.toml
:- set the account_id value (https://developers.cloudflare.com/fundamentals/setup/find-account-and-zone-ids/)
- open
src/config.ts
:- set the ethereum node address
- optionally override the subgraph address (default value will ratelimit)
- develop interactively with
wrangler dev
- publish the application:
wrangler deploy
Don't forget to set your ethereum node in src/config.ts
! Your node must be served from port 80 or 443- this is a limitation with Cloudflare, they don't seem to support reaching out to nonstandard ports.