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

Hacking ENS

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for Makoto Inoue Makoto Inoue
February 29, 2020
830

Hacking ENS

Avatar for Makoto Inoue

Makoto Inoue

February 29, 2020
Tweet

Transcript

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

    Ethereum Codeup - C-founder @wearekickback
  2. 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)
  3. 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
  4. 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
  5. 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
  6. Contract MyResolver { address me; function constructor() { me =

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

    PubKey - ABI - Text record - Multicoin https://github.com/ensdomains/resolvers
  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://docs.ens.domains/ • https://github.com/ensdomains/subdomain-registrar

    • https://github.com/ensdomains/ethregistrar • https://github.com/ensdomains/ens • https://github.com/ensdomains/resolvers