ERC-2544 ENS wildcard subdomain resolution (ENS Wildcard Resolution)

Stagnant · Names & metadata · created 2020-02-28

In ENS, this allows subdomains without a registered resolver to still have records such as addresses returned, by letting the parent domain's resolver resolve them instead.

Why it is needed

Until now, ENS required a resolver to be registered in the registry for every single name before its records could be found. For a wallet service or exchange to hand out ENS names in the form of subdomains to a large number of users, it had to submit an on-chain registration transaction for each subdomain and wait for it to be confirmed. The more users there were, the higher the cost grew, and users who had just created an account faced the inconvenience of not being able to use their name immediately until the transaction was mined. Because resolution for a subdomain with no resolver stopped right there, there was no way for the parent domain to step in and resolve it instead.

What to implement

In depth

Resolver lookup procedure

The client initially sets currentname to the original name (name) and calls ens.resolver(namehash(currentname)). If the result is not the zero address, it returns that resolver and stops. If it is the zero address and currentname is an empty name ('' or '.'), it returns null and resolution fails. Otherwise, it assigns to currentname the parent domain obtained by stripping the leftmost label via parent(currentname) and repeats the lookup. parent('foo.eth') is defined as 'eth', and parent('tld') is defined as the empty string.

resolve call and fallback procedure

After finding a resolver, the client builds ABI-encoded calldata for the requested record function (for example, addr()). It calls resolver.supportsInterface(0xTBD) to check EIP-2544 support; if supported, it calls resolver.resolve(dnsencode(name), calldata). If not supported, it calls the resolver's corresponding function directly with calldata. In either case, the return value is decoded according to the ABI return format of the original function (for example, addr()).

Distinguishing the original name from currentname

currentname (the name truncated to a parent domain) is used only during the resolver lookup step. Once a resolver is found, the resolve() function or individual record functions are always called with the original full name (name). This lets the resolver compute records while knowing the full original subdomain.

Why the DNS wire format is used

dnsencode uses the DNS name encoding method from RFC1035 Section 3.1, but without the overall length limit. An empty string is encoded as a single zero octet, the same as '.'. Dot-separated plain name notation requires scanning the entire string to find separators, but the DNS wire format was chosen because it allows name hashing and extracting or stripping individual labels to be handled gas-efficiently.

Why resolve() takes a plaintext name

The resolve() function takes the original name together with calldata, rather than a hash. This adds implementation complexity, but in exchange lets the resolver act based on the plaintext text of a label. For example, this makes it possible to resolve id.nifty.eth as the owner address of NFT number id in a specific collection, something that cannot be done with namehash alone. A resolver with simple requirements can skip implementing resolve() and just keep the existing record functions.

Backward compatibility

This standard works without changing the existing ENS registry or existing resolver contracts. An existing client that only complies with EIP-137 cannot resolve wildcard records and simply fails, but it continues to resolve or reject already-registered ordinary records as before. Conversely, a client that complies with EIP-2544 correctly handles both existing records and wildcard records. A resolver implementing resolve() for non-wildcard purposes should design its return values carefully for compatibility with legacy clients that call individual record functions directly.

Proposal status

This EIP is in Stagnant status, a proposal that is no longer actively discussed or has stalled. The interface ID value in the spec also remains unfinalized as 0xTBD.

Things to watch out for

Original ERC · ← ERCs