EIPs Explained

ERC-2544 · Stagnant · ERC · 2020-02-28

ERC-2544: ENS Wildcard Resolution

Lets an ENS client walk up to a parent name's resolver when a subdomain has none, so a project can serve unlimited subdomains like `alice.wallet.eth` without registering each one.

What problem does it solve?

Under EIP-137, resolving an ENS name is two steps: hash the name into a node, ask the ENS registry for that node's resolver, then ask the resolver for the record. If no resolver is set for that exact node, resolution simply fails.

Wallets, exchanges and dapps wanted to give every user a name like user123.app.eth. Doing that meant one registry transaction per user, which is expensive at scale and means the name is not usable until that transaction is mined.

ERC-2544 adds wildcard resolution: one resolver set on the parent can answer for any subdomain beneath it, without changing the registry or existing resolvers.

How it works

Finding the resolver. The client looks up the resolver for the full name. If it is the zero address, it strips the leftmost label and tries again (a.b.eth → b.eth → eth → root) until it finds a resolver or runs out of labels.

Calling the resolver. The record is always requested for the original name, not the parent where the resolver was found. Resolvers may also implement a new function:

function resolve(bytes calldata name, bytes calldata data) external view returns (bytes memory);
  • name is the full name in DNS wire format (length-prefixed labels), so the resolver can see the plaintext labels instead of only a hash.
  • data is the ABI-encoded call the client would have made, e.g. addr(namehash(name)).
  • The resolver returns that function's ABI-encoded result, or reverts if unsupported.

If the resolver advertises resolve via ERC-165, the client calls it; otherwise it calls the normal function (addr, text, …) directly. Seeing plaintext labels enables designs such as resolving 42.nifty.eth to the owner of NFT #42, or to a CREATE2 address derived from the label.

A resolver set directly on a subdomain still takes priority over the parent's wildcard.

Sample code

Client-side resolver lookup, mirroring the spec's pseudocode (ethers v6):

import { Contract, ZeroAddress, namehash, dnsEncode } from "ethers";

const parent = (name: string) => name.split(".").slice(1).join(".");

async function findResolver(registry: Contract, name: string) {
  for (let current = name; current !== ""; current = parent(current)) {
    const r: string = await registry.resolver(namehash(current));
    if (r !== ZeroAddress) return r;
  }
  return null; // resolution fails
}

// With an extended resolver: send the original name, DNS-encoded
// const data = iface.encodeFunctionData("addr(bytes32)", [namehash(name)]);
// const out  = await resolver.resolve(dnsEncode(name), data);

Recent versions of ethers and viem already implement this walk-up logic in their ENS helpers.

Things to know

  • Status is Stagnant in the EIP repository, and the spec leaves the resolve interface ID as 0xTBD. ENS has since adopted the design in its own ENSIP process, which is what libraries implement; check ENS documentation for the final interface ID.
  • Legacy EIP-137-only clients will not find wildcard records; they fail to resolve rather than resolve incorrectly.
  • Catch-all resolvers make typos dangerous: alcie.app.eth may resolve to a valid-looking address. Consider validating names or making funds recoverable.
  • resolve pairs naturally with ERC-3668 (CCIP-Read), which lets the resolver fetch records from off-chain sources.

#ens #naming #wildcard #resolver #subdomains

Details

Authors
Nick Johnson (@arachnid), 0age (@0age)
Status
Stagnant
Type
Standards Track / ERC
Created
2020-02-28
Requires

Machine-readable: Markdown · JSON