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

ENS Integration workshop @ EthDenver

Makoto Inoue
February 06, 2021
58

ENS Integration workshop @ EthDenver

Makoto Inoue

February 06, 2021
Tweet

Transcript

  1. None
  2. Agenda - 1. ENS 101 + Basic Integration Forward lookup/Reverse

    lookup/ ENS+IPFS - 2. Hacking ENS (Resolver) ENS internal / L2 integration, the ENS way - 3. Optional: Hacking ENS 2 (Subdomain Registrar)
  3. Read the doc (https://docs.ens.domains ) and join Discord(https://discord.gg/AskZbFx )

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

    - Frameworks: waffle/embark - ENS official library = ensjs
  5. 1: ENS 101 + Basic Integration

  6. 0x5a384227b65fa093dec...

  7. matoken.eth

  8. None
  9. .Adoption (174 wallets & dapps integrations)

  10. None
  11. Reverse Lookup (setting it via app.ens.domains)

  12. None
  13. Reverse Lookup (code)

  14. .Adoption (> 400k domains)

  15. @ensbot https://github.com/ensdomains/ens-twitter-api

  16. souljaboy.eth

  17. souljaboy.eth is NFT

  18. None
  19. IPFS + ENS = .eth.link https://medium.com/the-ethereum-name-service/cloudflare-and-fleek-make-ens-ipfs-site-deployment-as-easy-as-ever-262c990a7514 - Set contenthash (Fleek,Temporal,

    IPFS Pinata) - .eth works on Opera/Metamask/Status - .eth.link for other browsers (mainnet only) - Full detail in the blog post
  20. 2: Hacking ENS (Resolver)

  21. ENS Architecture (Registry & Resolver)

  22. Resolving a name

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

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

  25. ENS Resolver extension example: Multicoin support

  26. Hacking example

  27. - L2 platform agnostic (initially proposed by Vitalik) - No

    platform specific integration required for the end users - No added trust assumption L2 support (Goal) https://medium.com/the-ethereum-name-service/general-purpose-layer-2-static-calls-proposal-presentation-by-vit alik-buterin-at-ens-online-2d752906719e
  28. - Each domain owner chooses L1 by updating Resolver -

    Resolver returns L2 Gateway URL - Client revifies L2 data on L1 L2 support (How) https://medium.com/the-ethereum-name-service/a-general-purpose-bridge-for-ethereum-layer-2s-e28810ec1d88
  29. - User can verify L2 state from L1 (✔ Rollups

    , ? Plasma & State Channel) - User can verify that the data is signed by the same L2 validators (POA, POS, other chains, etc ) L2 support (No added trust assumption) https://github.com/ensdomains/l2gateway-demo/compare/optimism
  30. 3. Optional: Hacking ENS 2 (Subdomain Registrar)

  31. Subdomain = new hotmail

  32. ENS + NFT + Virtual Space

  33. .dcl.eth

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

  35. Custom Registrar (Decentraland)

  36. Custom Registrar (Decentraland)

  37. 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); } }
  38. 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); } }
  39. 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, } }
  40. 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, } }
  41. Deriving subdomainLabelHash (aka: tokenID in ERC721) > BigInt(sha3('makoto')).toString() '10875058607269583767816895413117596491787975435502696954128626264198231

  42. 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); } }
  43. For more info • https://app.ens.domains • https://discord.gg/AskZbFx • https://docs.ens.domains •

    https://medium.com/the-ethereum-name-service/cloudflare-and-fleek-make-ens-ipfs-site-deployment-as-easy-as-ever-262c990a7514 • https://almonit.eth.link/ • https://github.com/ensdomains/ens-twitter-api • https://medium.com/the-ethereum-name-service/a-general-purpose-bridge-for-ethereum-layer-2s-e28810ec1d88 • https://github.com/ensdomains/l2gateway-demo ENS smart contracts • https://github.com/ensdomains/ethregistrar • https://github.com/ensdomains/ens • https://github.com/ensdomains/resolvers • https://github.com/ensdomains/subdomain-registrar
  44. None