Custom Top-Level Domain (TLD) Registration

Overview

You can create your own TLD (e.g., .custom) or sublevel domains by deploying a BaseRegistrar contract and configuring it with the PNS Registry.

Step-by-Step Process

  1. Calculate Node Hash

const labelHash = keccak256('custom');
const rootNode = '0x0000000000000000000000000000000000000000000000000000000000000000';
const nodeHash = keccak256(rootNode + labelHash);
  1. Deploy BaseRegistrar

// Deploy new registrar for your TLD
const baseRegistrar = await BaseRegistrar.deploy(
    PNS_REGISTRY_ADDRESS,
    nodeHash
);
  1. Set Registrar as Owner

// Through PNS Registry
await pnsRegistry.setSubnodeOwner(
    rootNode,
    labelHash,
    baseRegistrar.address
);
  1. Configure Registrar

// Set resolver
await baseRegistrar.setResolver(PUBLIC_RESOLVER_ADDRESS);

Example Configuration

const PNS_REGISTRY = "0x123..."; // PNS Registry address
const PUBLIC_RESOLVER = "0x456..."; // Default resolver

// Deploy TLD Registrar
const customRegistrar = await BaseRegistrar.deploy(
    PNS_REGISTRY,
    namehash("custom")
);

// Set as owner in registry
await pnsRegistry.setSubnodeOwner(
    "0x0",
    keccak256("custom"),
    customRegistrar.address
);

Last updated