ensdomains / ens

Implementations for ENS core functionality: The registry, registrars, and public resolvers.
https://ens.domains/
BSD 2-Clause "Simplified" License
1.16k stars 511 forks source link

Need a guide for setting up reverse registration of smart contracts #332

Closed Garoth closed 5 years ago

Garoth commented 5 years ago

Hey guys, sorry if I missed it, but there really needs to be a clear guide for setting up the reverse resolution of smart contracts

I'm the owner of flowerpatch.app and related FLOWER contracts. I'd love to be able to set up my flowerpatch.ens to point to the main FLOWER contract, but reverse name resolution requires you to be logged in as the address -- which is not really possible for a contract. It seems like the way you can achieve reverse resolution is either by modifying the smart contract to have certain functions included, or perhaps by implementing a custom resolver. Upgrading my existing contracts seems undesirable currently, and I couldn't find clear instructions on a less invasive method.

Alternatively, could it be possible to allow the "contract owner / creator" to set the reverse lookup on behalf of a contract? That would make life a lot simpler

Arachnid commented 5 years ago

You're right - the contract needs to call a function to set its name, or to set the owner of the reverse record when it's constructed. Documentation for this is here; the simplest route is to put this in the constructor:

reverseRegistrar.claim(msg.sender)

We can't assume that the creator of a contract has the right to do that, because the creator doesn't generally have any special permissions over a contract.