PNS
  • PNS: Your Identity in Polkadot
  • Summary
  • Advanced Topics
  • Contributing
  • Core Concepts
  • FAQ & Troubleshooting
  • PNS Troubleshooting Guide
  • PNS User Guide
  • advanced-topics
    • Contract Deployments
    • Custom Resolvers
    • Custom Top-Level Domain (TLD) Registration
    • Subdomain Management
  • contributing
    • GitHub Workflow
    • Contribution Guidelines
    • Issue Reporting
  • faq
    • Common Issues
    • Technical FAQ
Powered by GitBook
On this page
  • Overview
  • Step-by-Step Process
  • Example Configuration
  1. advanced-topics

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
);
PreviousCustom ResolversNextSubdomain Management

Last updated 3 days ago