tomi Domains
tomi Domains
tomi Domains
  • Introduction
    • Domains
      • Terminology
      • Frequently Asked Questions
      • Domains Deployments
      • Registrar Frequently Asked Questions
      • DNS Registrar guide
      • Domains Improvement Proposals
      • DomainsIP-2: Initial Hash Registrar
      • DomainsIP-3: Reverse Resolution
      • DomainsIP-4: Support for contract ABIs
      • DomainsIP-5: Text Records
      • DomainsIP-6: DNS-in-Domains
      • DomainsIP-7: Interface Discovery
      • DomainsIP-8: Multichain Address Resolution
      • DomainsIP-9: Wildcard Resolution
      • DomainsIP-10: EVM compatible Chain Address Resolution
      • DomainsIP-11: Avatar Text Records
      • DomainsIP-12: SAFE Authentication for Domains
      • DomainsIP-13: On-chain Source Parameter
      • Dapp Developer Guide
      • Managing Names
      • Registering & Renewing Names
      • Domains Front-End Design Guidelines
      • Domains AS NFT
      • Domains Layer2 and offchain data support
      • Domains Data guide
      • Name Processing
      • Registry
      • ReverseRegistrar
      • TestRegistrar
      • PublicResolver
      • .tomi Permanent Registrar
        • Registrar
        • Controller
      • DNS Registrar
      • Subgraph
        • Query Examples
      • Resolving Names On-chain
      • Writing a Resolver
      • Writing a Registrar
      • Guide for DApp Developers
      • Technical Description
Powered by GitBook
On this page
  1. Introduction
  2. Domains

Writing a Registrar

A registrar in Domains is simply any contract that owns a name, and allocates subdomains of it according to some set of rules defined in the contract code. A trivial first in first served contract is demonstrated below:

contract FIFSRegistrar {
   TDNS tdns;
   bytes32 rootNode;

   function FIFSRegistrar(address tdnsAddr, bytes32 node) {
       tdns = TDNS(tdnsAddr);
       rootNode = node;
   }

   function register(bytes32 subnode, address owner) {
       var node = sha3(rootNode, subnode);
       var currentOwner = tdns.owner(node);
       if (currentOwner != 0 && currentOwner != msg.sender) throw;
       tdns.setSubnodeOwner(rootNode, subnode, owner);
   }
}

You may wish to set custom rules for the allocation of new names to your users; the rules you set are entirely up to you.

You should also bear in mind that as long as you retain ownership of the parent name - either directly or through another contract - your users have no guarantee that you will not take back ownership of their names and change what they resolve to. You may wish to consider committing ownership of the name to a contract that restricts your ability to control it.

PreviousWriting a ResolverNextGuide for DApp Developers

Last updated 9 months ago