Integration with ENS (Ethereum Name Service)
ENS is the de facto standard for human-readable addresses in the Ethereum ecosystem. Instead of building your own naming service, most dApps simply integrate ENS: display names instead of addresses, accept name input in transfer fields, show avatars.
Name Resolution in Code
Frontend via ethers.js / viem
// ethers.js v6
const provider = new ethers.JsonRpcProvider(RPC_URL);
// Forward resolution: name → address
const address = await provider.resolveName("vitalik.eth");
// "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
// Reverse resolution: address → name
const name = await provider.lookupAddress("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045");
// "vitalik.eth" or null if reverse record not set
// Avatar
const resolver = await provider.getResolver("vitalik.eth");
const avatar = await resolver?.getAvatar();
// Avatar URL or null
// viem
import { createPublicClient, http } from "viem";
import { mainnet } from "viem/chains";
import { normalize } from "viem/ens";
const client = createPublicClient({ chain: mainnet, transport: http() });
const address = await client.getEnsAddress({ name: normalize("vitalik.eth") });
const name = await client.getEnsName({ address: "0xd8dA..." });
const avatar = await client.getEnsAvatar({ name: normalize("vitalik.eth") });
normalize() is important: ENS names are normalized per UTS-46 standard before hashing. Vitalik.ETH and vitalik.eth — one name, but without normalize() they give different namehashes.
On-chain Resolution
interface IENSResolver {
function addr(bytes32 node) external view returns (address);
}
interface IENS {
function resolver(bytes32 node) external view returns (address);
}
contract ENSConsumer {
IENS constant ENS_REGISTRY = IENS(0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e);
function resolveENS(bytes32 namehash) external view returns (address) {
address resolverAddr = ENS_REGISTRY.resolver(namehash);
require(resolverAddr != address(0), "No resolver");
return IENSResolver(resolverAddr).addr(namehash);
}
}
Namehash for alice.eth needs to be computed off-chain (or via ENS SDK) and passed to the contract — on-chain string namehash computation is expensive.
Text Records and Profiles
ENS stores arbitrary text records by key:
const resolver = await provider.getResolver("alice.eth");
const email = await resolver?.getText("email");
const twitter = await resolver?.getText("com.twitter");
const github = await resolver?.getText("com.github");
const website = await resolver?.getText("url");
const description = await resolver?.getText("description");
Standard keys (EIP-634): email, url, avatar, description, notice, keywords, com.twitter, com.github, com.discord, org.telegram.
This is the foundation for ENS-based profiles: everything needed is stored in resolver, read without additional infrastructure.
Integration Complexity Guidelines
| Function | Complexity | Timeline |
|---|---|---|
| Display name instead of address | Minimal | 0.5 day |
| ENS input in transfer field | Minimal | 1 day |
| Avatar in UI | Low | 1 day |
| Text records / profile | Low | 1-2 days |
| On-chain resolution in contract | Medium | 2-3 days |
Basic ENS integration into existing dApp — 2-3 working days.







