New standard proposal: ENS CNAME support

I’ve written up a draft EIP proposing a new resolver field cname to support name aliases on ENS.

Not a fan of this proposal, it would lead to inconsistent resolution if library A knew about CNAMEs and library B didn’t.

How about writing a resolver that contained a simple mapping (bytes32=>bytes32) that would map source to target nodes, and a fallback function that:

  • fetches the value of the requested node in the mapping
  • replaces the resultant value in the transaction data
  • fetches the resolver for the resultant node
  • forwards the transaction to the resolver

This would no doubt require a bit of cleverness in the contract but would operate with existing clients and future profiles.


Hi! Sounds great, but it looks more like a Proxy Pattern. How could you prevent loops?

This is my preferred approach, too.

Do you think it’s good to support both interfaces? I would say

  • when resolving fails, fallback to cname
  • it can also be solved via proxy pattern, no-loops relies on client

Anyway, here’s the cname resolver impl

One issue is that doing this requires a check in every resolver method to see whether a CNAME exists so it can redirect - and another one for the fallback function. A dedicated ‘CNAME resolver’ can be much simpler.

I made some updates following @jgm proposal. Looks better now. Thanks!

Hi! I’m adding two items to the spec:

  • function cname(bytes32) exposing a name’s cname
  • event CnameChanged(bytes32 name, bytes32 canonical)

I think that with this two things eip-2375 would be ready for becoming a standard. What do you think?

I think it’d be a good idea to add those functions, yes.

I don’t think this needs to be an EIP any longer, though - just a contract implementation. I’m also pretty sure you can cut a lot of the inline assembly out by using the delegatecall Solidity builtin on the address type.

Still, this is a really useful contribution - thanks! If you wanted to write it up as a PR to the resolvers repo, with tests, I’d be glad to add it.