Core Concepts

Overview

🐡 PNS (Polkadot Name Service) is a distributed, open, and extensible naming system built on the Polkadot ecosystem. Similar to ENS (Ethereum Name Service), PNS allows human-readable names to be mapped to Polkadot addresses and other resources.

Core Components

1. Registry

The registryarrow-up-right is the core contract of PNS. It keeps track of all domains and subdomains, storing three critical pieces of information:

  • The owner of the domain

  • The resolver for the domain

  • The time-to-live (TTL) for all records under the domain

2. Registrars

Registrars are contracts that own a domain and specify rules for the allocation of their subdomains. The primary registrar in PNS is the .dot registrar, which allows users to register second-level domains. BaseRegistrararrow-up-right is simple implemmentation of a registrar and be extended to include additional business logic.

3. Resolvers

Resolvers are responsible for the process of translating names into addresses. A resolver can implement any number of public resolution interfaces that other smart contracts or external clients can query.

Key resolver features:

Name Structure and Hashing

Name Syntax

Names in PNS follow a hierarchical dot-separated format:

Example: "wallet.dot" or "sub.wallet.dot"

Important Rules:

  • Labels must be normalized according to UTS46 rules

  • Case-insensitive (folded during normalization)

  • Recommended length: max 64 chars per label, 255 chars total name

Namehash Algorithm

Names are processed using the namehash algorithm to create unique fixed-length identifiers:

Example hashes:

System Architecture

Smart Contract Architecture

Core Components:

  1. PNSRegistry.sol

  • Central registry contract

  • Maintains ownership and resolver mapping

  • Controls domain and subdomain creation

  1. BaseRegistrar.sol

  • Manages the registration of second-level domains

  • Implements domain expiration and renewal logic

  • Can be extended to implement controls pricing and registration rules

  1. Resolvers

  • PublicResolver.sol: Basic name resolution

  • MetadataResolver.sol: Additional metadata storage

Contract Interactions

Frontend Architecture

The frontend application is built using Next.js and provides:

  • Domain search and registration interface

  • Domain management dashboard

  • Resolver configuration

  • Integration with Polkadot wallets

Key Features

  1. Human-Readable Names

    • Transform complex Polkadot addresses into memorable names

    • Support for multiple name formats

  2. Decentralized Operation

    • Fully on-chain resolution

    • No central authority

    • Community-driven governance

  3. Extensibility

    • Custom resolvers can be implemented

    • Support for various record types

    • Upgradeable architecture

  4. Security

    • Based on proven ENS architecture

    • Secure ownership model

    • Protected against common attack vectors

Technical Workflow

  1. Registration Process

  2. Resolution Process

  3. Update Process

Last updated