Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Hacking ENS

1eecfce54b4f902784d046328935efd4?s=47 Makoto Inoue
February 29, 2020
300

Hacking ENS

1eecfce54b4f902784d046328935efd4?s=128

Makoto Inoue

February 29, 2020
Tweet

Transcript

  1. EthLondon, Feb 2020 Makoto Inoue (makoto@ens.domains)

  2. Speaker (@makoto_inoue) - Dev at @ensdomains - Organiser @ London

    Ethereum Codeup - C-founder @wearekickback
  3. London Ethereum Codeup

  4. Kickback (Current #) 157 / 212 = 74% 4240 /

    157 = 27 DAI
  5. ENS Hackathon 2018

  6. ENS Permanent Registrar Migration - 2019 May

  7. ENS is NFT https://opensea.io/rankings

  8. NFT Universe

  9. ENS will award three total prizes of $600, $300, and

    $100 for the top three projects that create a new feature for ENS (e.g. in the Manager, Public Resolver, or some other part of ENS)
  10. • .eth • Build your • May 4th 2020 Some

    Hacking ideas
  11. Agenda - 1. ENS 101 - 2. BYO Resolver -

    3. BYO Registrar
  12. 1: ENS 101

  13. What is ENS? 0x5a384227b65fa093dec...

  14. What is ENS? matoken.eth

  15. .Adoption (> 400k domains)

  16. .Adoption (32 wallets, 80 dapps)

  17. Read the doc! (https://docs.ens.domains )

  18. Resolving name (aka forward lookup)

  19. Resolving address (aka reverse lookup)

  20. Resolving address (aka reverse lookup)

  21. 2: BYO Resolver

  22. ENS Architecture (Registry & Resolver)

  23. contract ENSRegistry{ function _setOwner(bytes32 node, address owner) internal { records[node].owner

    = owner; } function setOwner(bytes32 node, address owner) public authorised(node) function setSubnodeOwner(bytes32 node, bytes32 label, address owner) function resolver(bytes32 node) public view returns (address) { return records[node].resolver; } } ENS by example: Registry
  24. contract ENSRegistry{ function _setOwner(bytes32 node, address owner) internal { records[node].owner

    = owner; } function setOwner(bytes32 node, address owner) public authorised(node) function setSubnodeOwner(bytes32 node, bytes32 label, address owner) function resolver(bytes32 node) public view returns (address) { return records[node].resolver; } } ENS by example: Registry
  25. contract ENSRegistry{ function _setOwner(bytes32 node, address owner) internal { records[node].owner

    = owner; } function setOwner(bytes32 node, address owner) public authorised(node) function setSubnodeOwner(bytes32 node, bytes32 label, address owner) function resolver(bytes32 node) public view returns (address) { return records[node].resolver; } } ENS by example: Registry
  26. Resolving a name

  27. Contract MyResolver { address me; function constructor() { me =

    msg.sender; } function addr(bytes32 node) constant returns (address) { return me; } } ENS by example: Resolvers
  28. ENS Architecture (Registry & Resolver) - Address - Contenthash -

    PubKey - ABI - Text record - Multicoin https://github.com/ensdomains/resolvers
  29. .art

  30. Duckduckgotor.eth -> onion://3g2up14pq6kufc4m

  31. ENSLogin ( EthBerlin 2019)

  32. 3: BYO Registrar

  33. Subdomain = new hotmail

  34. ENS + NFT + Virtual Space

  35. .dcl.eth

  36. ENS Architecture (Registrar) Registrar FIFSRegistrar ETHRegistrar DNSRegistrar Subdomain

  37. Custom Registrar (Decentraland)

  38. Custom Registrar (Decentraland)

  39. Custom Registrar (Decentraland) contract DCLRegistrar is ERC721Full, Ownable { constructor(

    IENSRegistry _registry, IBaseRegistrar _base ) public ERC721Full("DCL Registrar", "DCLENS") { // ENS registry updateRegistry(_registry); // ENS base registrar updateBase(_base); } }
  40. Custom Registrar (Decentraland) contract DCLRegistrar is ERC721Full, Ownable { constructor(

    IENSRegistry _registry, IBaseRegistrar _base ) public ERC721Full("DCL Registrar", "DCLENS") { // ENS registry updateRegistry(_registry); // ENS base registrar updateBase(_base); } }
  41. Custom Registrar (Decentraland) contract DCLRegistrar is ERC721Full, Ownable { function

    _register( string memory _subdomain, bytes32 subdomainLabelHash, address _beneficiary, uint256 _createdDate ) internal { // Create new subdomain and assign the _beneficiary as the owner registry.setSubnodeOwner(domainNameHash, subdomainLabelHash, _beneficiary); // Mint an ERC721 token with the sud domain label hash as its id _mint(_beneficiary, uint256(subdomainLabelHash)); // Map the ERC721 token id with the subdomain for reversion. subdomains[subdomainLabelHash] = _subdomain; // Emit registered name event emit NameRegistered(msg.sender, _beneficiary, subdomainLabelHash, _subdomain, } }
  42. Custom Registrar (Decentraland) contract DCLRegistrar is ERC721Full, Ownable { function

    _register( string memory _subdomain, bytes32 subdomainLabelHash, address _beneficiary, uint256 _createdDate ) internal { // Create new subdomain and assign the _beneficiary as the owner registry.setSubnodeOwner(domainNameHash, subdomainLabelHash, _beneficiary); // Mint an ERC721 token with the sud domain label hash as its id _mint(_beneficiary, uint256(subdomainLabelHash)); // Map the ERC721 token id with the subdomain for reversion. subdomains[subdomainLabelHash] = _subdomain; // Emit registered name event emit NameRegistered(msg.sender, _beneficiary, subdomainLabelHash, _subdomain, } }
  43. Deriving subdomainLabelHash (aka: tokenID in ERC721) > BigInt(sha3('makoto')).toString() '10875058607269583767816895413117596491787975435502696954128626264198231

  44. A few extra steps Contract MyAweSomeApp { function register(bytes32 label)

    public { bytes32 node = getNode(label); require(ens.owner(node) == address(0)) ens.setSubnodeOwner(rootNode, label, this); ens.setResolver(node, resolver); resolver.setAddr(node, msg.sender); ens.setOwner(node, msg.sender); } }
  45. A few extra steps

  46. For more info • • https://app.ens.domains/ • https://docs.ens.domains/ • https://github.com/ensdomains/subdomain-registrar

    • https://github.com/ensdomains/ethregistrar • https://github.com/ensdomains/ens • https://github.com/ensdomains/resolvers
  47. Thank you! Demo: http://happywedding.julietandnick.eth.link Makoto Inoue / makoto@ens.domains