Skip to main content
The FIFSRegistrar (First-In-First-Served Registrar) is a simple registrar contract that allocates subdomains to the first person to claim them. It provides a straightforward way to distribute subdomains under a parent node.

Overview

FIFSRegistrar provides:
  • Simple first-come-first-served subdomain registration
  • Re-registration capability for existing owners
  • No expiration - registrations are permanent until transferred
  • Minimal registration logic with low gas costs

Import

import '@ensdomains/ens-contracts/contracts/registry/FIFSRegistrar.sol';

Constructor

constructor(ENS ensAddr, bytes32 node) public
Creates a new FIFS registrar.
ensAddr
ENS
required
The address of the ENS registry
node
bytes32
required
The node that this registrar administers (e.g., the hash of ‘myname.eth’)

State Variables

ens

ENS ens
Reference to the ENS registry contract.

rootNode

bytes32 rootNode
The parent node that this registrar has authority over.

Modifiers

only_owner

modifier only_owner(bytes32 label)
Ensures that only unregistered subdomains (owner is address(0x0)) or the current owner can register/update a subdomain.
label
bytes32
required
The hash of the label to check

Functions

register

function register(bytes32 label, address owner) public only_owner(label)
Registers a name or changes the owner of an existing registration.
label
bytes32
required
The hash of the label to register (e.g., keccak256(‘subdomain’))
owner
address
required
The address of the new owner
This function can only be called if:
  • The subdomain is currently unregistered (owner is address(0x0)), OR
  • The caller is the current owner of the subdomain

How It Works

  1. The FIFSRegistrar is deployed with a reference to the ENS registry and a parent node it controls
  2. The deployer must transfer ownership of the parent node to the FIFSRegistrar contract
  3. Users can call register() with a label hash and owner address
  4. The registrar checks if the subdomain is available or if the caller is the current owner
  5. If authorized, it creates/updates the subdomain using ens.setSubnodeOwner()

Usage Examples

import '@ensdomains/ens-contracts/contracts/registry/FIFSRegistrar.sol';
import '@ensdomains/ens-contracts/contracts/registry/ENS.sol';

// Assume we own 'myapp.eth' and want to let users register subdomains
ENS ens = ENS(0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e);
bytes32 myAppNode = 0x1234...; // namehash('myapp.eth')

// Deploy the registrar
FIFSRegistrar registrar = new FIFSRegistrar(ens, myAppNode);

// Transfer ownership of 'myapp.eth' to the registrar
ens.setOwner(myAppNode, address(registrar));

// Now anyone can register subdomains under myapp.eth

Use Cases

Application Subdomains

Allow users of your dApp to claim personalized subdomains:
  • alice.myapp.eth
  • bob.myapp.eth
  • dao.myapp.eth

Organization Structure

Create subdomains for different parts of an organization:
  • engineering.company.eth
  • marketing.company.eth
  • sales.company.eth

Simple Name Distribution

Provide a straightforward way to distribute names without complex auction mechanics or pricing.

Limitations

  • No built-in expiration mechanism - names are permanent unless transferred
  • No pricing mechanism - registration is free (only gas costs)
  • No name length restrictions - single character names can be claimed
  • Vulnerable to frontrunning - miners or MEV searchers can see and claim names first
  • No reclaim mechanism for the parent node owner

Comparison with TestRegistrar

Unlike the FIFSRegistrar:
  • TestRegistrar includes automatic expiration (4 weeks)
  • TestRegistrar allows re-registration after expiration by anyone
  • TestRegistrar is designed specifically for test networks
Choose FIFSRegistrar for permanent subdomain allocation, or TestRegistrar for temporary test environments.

Build docs developers (and LLMs) love