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

ENS Integration workshop @ EthDenver

Makoto Inoue
February 06, 2021
120

ENS Integration workshop @ EthDenver

Makoto Inoue

February 06, 2021
Tweet

Transcript

  1. 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)
  2. Your library may already support ENS - Libraries = web3.js/ethers.js/web3.py/web3j

    - Frameworks: waffle/embark - ENS official library = ensjs
  3. 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
  4. ENS Architecture (Registry & Resolver) - Address - Contenthash -

    PubKey - ABI - Text record - Multicoin https://github.com/ensdomains/resolvers
  5. - 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
  6. - 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
  7. - 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
  8. 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); } }
  9. 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); } }
  10. 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, } }
  11. 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, } }
  12. 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); } }
  13. 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