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

EthGlobal ENS workshop

Makoto Inoue
September 03, 2021

EthGlobal ENS workshop

Makoto Inoue

September 03, 2021
Tweet

More Decks by Makoto Inoue

Other Decks in Technology

Transcript

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

    Hacking ENS Resolver - 3. Hacking ENS Registrar 💰 $3000 EthGlobal hackathon prize
  2. Your library may already support ENS - Libraries = web3.js/ethers.js/web3.py/web3j

    - Frameworks: waffle/embark/scaffold-eth - ENS official library = ensjs
  3. ENS Architecture (Registry & Resolver) - Address - Contenthash -

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