DEV Community

neuralmint
neuralmint

Posted on

ENS Resolver CLI — Look Up Any ENS Name from Your Terminal

So you want to know what Ethereum address is behind an ENS name like vitalik.eth? Or maybe you got an address and need to find its ENS name? Say hello to ens_resolver — a single-file Python CLI that does exactly that, with zero pip dependencies.

What It Does

ens_resolver is a lightweight CLI tool that talks directly to the Ethereum network via a public JSON-RPC endpoint. It implements the ENS specification (EIP-137) from scratch — namehash algorithm, ABI encoding, and all.

Two subcommands:

python3 ens_resolver.py resolve vitalik.eth
vitalik.eth  →  0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045

python3 ens_resolver.py reverse 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045
0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045  →  vitalik.eth
Enter fullscreen mode Exit fullscreen mode

Need machine-readable output? Add --json:

python3 ens_resolver.py --json resolve nick.eth
{"name": "nick.eth", "address": "0xb8c2C29ee19D8307cb7255e1Cd9CbDE883A267d5"}
Enter fullscreen mode Exit fullscreen mode

How It Works

Under the hood, ens_resolver:

  1. Computes the namehash of the ENS name (the recursive hash defined in EIP-137)
  2. Calls resolver() on the ENS registry contract (0x0000...d2e1e) to get the resolver address
  3. Calls addr() on the resolver to get the resolved wallet address

For reverse lookups, it follows the *.addr.reverse pattern:

  1. Reverses the address into 0x...addr.reverse
  2. Computes the namehash
  3. Gets the resolver and calls name(bytes32) to read the ENS name

Why Not Just Use Etherscan?

  • No browser needed — works from a terminal, SSH session, or CI pipeline
  • Scriptable — JSON output for piping into other tools
  • Lightweight — single file, pure Python
  • Fast — direct JSON-RPC calls, no page loads

Tech Stack

  • Python 3 (stdlib: argparse, urllib, json, re)
  • pycryptodomex for Keccak-256 hashing (Ethereum-compatible, distinct from SHA3)
  • Public Ethereum JSON-RPC endpoint (configurable via ENS_RPC_URL env var)

The ENS resolution is implemented from scratch using the actual smart contract ABI — function selectors, ABI encoding, and response decoding are all done manually with Python stdlib.

Install

No pip install nonsense for the tool itself — just grab the file:

curl -L https://raw.githubusercontent.com/neuralmint/ens-resolver-cli/main/ens_resolver.py -o ens_resolver.py
pip3 install pycryptodomex  # only dep, for Keccak-256 hashing
chmod +x ens_resolver.py
python3 ens_resolver.py --help
Enter fullscreen mode Exit fullscreen mode

Or clone the repo:

git clone https://github.com/neuralmint/ens-resolver-cli.git
cd ens-resolver-cli
python3 ens_resolver.py resolve vitalik.eth
Enter fullscreen mode Exit fullscreen mode

Use Cases

  • Scripting — batch-resolve a list of ENS names from a file
  • Monitoring — check if a name resolves to the expected address
  • Portfolio tools — map ENS names to addresses for balance checks
  • Reverse lookups — find the ENS name behind any Ethereum address

Support

If this tool saves you time, consider tossing a tip:

SOL: 4TGyiYBjaYhFFPNYyCoJjf16ctUsWVBiMR1FXQxEfhWi

ETH: 0xe07f177E0725c11EEc8BeA34C5b5193CaF2a1A6a


Built with Python. MIT licensed. Part of the neuralmint CLI Tools series.

Top comments (0)