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

EthGlobal ENS workshop

1eecfce54b4f902784d046328935efd4?s=47 Makoto Inoue
September 03, 2021

EthGlobal ENS workshop

1eecfce54b4f902784d046328935efd4?s=128

Makoto Inoue

September 03, 2021
Tweet

Transcript

  1. ENS integration workshop EthGlobal September 2021 Makoto Inoue (makoto@ens.domains)

  2. Agenda - 1. ENS Integration 101 - 2. ENS Resolver

    - 3. ENS Registrar
  3. Agenda - 1. ENS 101 + Basic Integration - 2.

    Hacking ENS Resolver - 3. Hacking ENS Registrar 💰 $3000 EthGlobal hackathon prize
  4. Read the doc (https://docs.ens.domains ) and join Discord(https://discord.gg/AskZbFx )

  5. 1: ENS Integration 101

  6. Your library may already support ENS - Libraries = web3.js/ethers.js/web3.py/web3j

    - Frameworks: waffle/embark/scaffold-eth - ENS official library = ensjs
  7. What is ENS? 0x5a384227b65fa093dec...

  8. Forward lookup matoken.eth

  9. .Adoption (> 300k domains)

  10. Forward lookup

  11. Reverse lookup

  12. Reverse Lookup (setting it via app.ens.domains)

  13. Reverse lookup (code)

  14. 2: ENS Resolver

  15. ENS Architecture (Registry & Resolver)

  16. Resolving a name

  17. ENS Architecture (Registry & Resolver) - Address - Contenthash -

    PubKey - ABI - Text record - Multicoin https://github.com/ensdomains/resolvers
  18. ENS Resolver extension example: Multicoin support

  19. ENS Resolver extension example: Multicoin support

  20. ENS Resolver extension example: Text record

  21. Text record use case: avatar pfp

  22. Text record use case scenario: avatar pfp https://gist.github.com/Arachnid/9db60bd75277969ee1689c8742b75182

  23. Text record use case scenario: avatar pfp https://gist.github.com/Arachnid/9db60bd75277969ee1689c8742b75182

  24. Text record use case scenario: avatar pfp

  25. metadata.ens.domains https://metadata.ens.domains/avatar/matoken.eth/meta (Rinkeby ENS+ Mainnet NFT)

  26. metadata.ens.domains https://metadata.ens.domains/docs https://github.com/ensdomains/ens-metadata-service

  27. - Each domain owner chooses L1 by updating Resolver -

    Resolver returns L2 Gateway URL - Client revifies L2 data on L1 Offchain support (Durin) https://github.com/ensdomains/durin https://github.com/ensdomains/l2gateway-demo
  28. 3. ENS Registrar

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

  30. .dcl.eth

  31. Custom Registrar (Decentraland)

  32. Custom Registrar (Decentraland)

  33. 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); } }
  34. 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); } }
  35. 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, } }
  36. 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, } }
  37. 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); } }
  38. For more info • https://app.ens.domains • https://discord.gg/AskZbFx • https://docs.ens.domains •

    https://github.com/ensdomains/eth-contrtacts • https://github.com/ensdomains/ens-metadata-service • https://metadata.ens.domains/docs • https://github.com/ensdomains/durin • https://github.com/ensdomains/l2gateway-demo
  39. Thank you! Makoto Inoue / makoto@ens.domains