🤖
LNS Documentation
  • Introduction
  • Terminology
  • Frequently Asked Questions
  • Tokenomics
  • LNS Deployments
  • Registrar Frequently Asked Questions
  • Deploying LNS on a Private Chain
  • DNS Registrar guide
  • Bug Bounty Program
  • ENS Improvement Proposals
    • ENSIP-1: ENS
    • ENSIP-2: Initial Hash Registrar
    • ENSIP-3: Reverse Resolution
    • ENSIP-4: Support for contract ABIs
    • ENSIP-5: Text Records
    • ENSIP-6: DNS-in-ENS
    • ENSIP-7: Contenthash field
    • ENSIP-8: Interface Discovery
    • ENSIP-9: Multichain Address Resolution
    • ENSIP-10: Wildcard Resolution
    • ENSIP-11: EVM compatible Chain Address Resolution
    • ENSIP-12: Avatar Text Records
  • Dapp Developer Guide
    • LNS Enabling your DApp
    • LNS Libraries
    • Working with LNS
    • Resolving Names
    • Managing Names
    • Registering & Renewing Names
    • LNS Front-End Design Guidelines
    • LNS as NFT
  • Contract API Reference
    • Name Processing
    • Registry
    • ReverseRegistrar
    • PublicResolver
    • .bch Permanent Registrar
      • Registrar
      • Controller
    • DNS Registrar
  • Contract Developer Guide
    • Resolving Names On-chain
    • Writing a Resolver
    • Writing a Registrar
    • LNS Support Chat
Powered by GitBook
On this page
Edit on GitHub

Last updated 3 years ago

This contract implements the core functionality of the permanent registrar, with the following features:

  • The owner of the registrar may add and remove 'controllers'.

  • Controllers may register new domains and extend the expiry of (renew) existing domains. They can not change the ownership or reduce the expiration time of existing domains.

  • Name owners may transfer ownership to another address.

  • Name owners may reclaim ownership in the LNS registry if they have lost it.

  • Owners of names in the legacy registrar may transfer them to the new registrar, during the 1 year transition period. When they do so, their deposit is returned to them in its entirety.

This section documents the parts of the registrar interface relevant to implementers of tools that interact with it. Functionality exclusive to the registrar owner or to controllers is omitted for brevity.

The registrar works exclusively with label hashes - the keccak256 of the first component of the label (eg, keccak256('ens') for ens.eth). For compatibility with ERC721, these are expressed as uint256 values rather than bytes32, but can be cast backwards and forwards transparently. The namehash of a name can be derived by computing keccak256(baseNode, labelHash), where basenode is the namehash of the TLD the registrar manages - eg, namehash('bch').

Registrations and renewals are handled via the .

Names and Registrations

All names inside LNS have an owner. The owner of a name can transfer the name to a new owner, set a resolver, and create and reassign subdomains. This functionality is all contained in the .

Allocation of names directly under .bch (eg, second-level domains ending with .eth, such as alice.bch) is governed by the .bch Permanent Registrar, described here. While buying a name from the registrar grants ownership of it in LNS, the registrar itself keeps independent track of who owns the registration. The concept of a registrant - the owner of a registration - is unique to the .bch permanent registrar.

The registrant of a name can transfer the registration to another account, and they can recover ownership of the name by calling , which resets ownership of the LNS name to the registrant's account.

Separating the concept of owning a name from owning a registration makes it possible to more easily build systems that make automated updates to LNS. The registrant can transfer ownership of the name to another account or to a smart contract that manages records, subdomains, etc, while still retaining the ability to recover ownership for upgrades, or in the case of a compromise.

When thinking about ownership, it's important to be clear whether you're considering ownership of the name or the registration.

Read Operations

Get Name Expiry

Returns the unix timestamp at which a registration currently expires. Names that do not exist or are not yet migrated from the legacy registrar will return 0.

Check Name Availability

Get Transfer Period End

transferPeriodEnds documents the unix timestamp at which it is no longer possible to migrate over registrations from the legacy registrar, and any non-migrated registrations become available for registration by anyone.

Get Controller Status

controllers allows callers to check if the supplied address is authorized as a registrar controller.

Check Token Approval

Returns the address of the approved operator for this name.

This function is part of ERC721.

Check All Tokens Approval

Returns true if operator is authorized to transfer all tokens for owner.

This function is part of ERC721.

Get Name Owner

ownerOf returns the address that owns the registration identified by the label hash, or reverts if the registration does not exist. Registrations that have not yet been migrated from the legacy registrar are treated the same as registrations that do not exist.

Write Operations

Transfer a Name

These functions transfer the registration.

Emits the following event on a successful transfer:

Approve Operator

Reclaim LNS Record

Sets the owner record of the name in the LNS registry to match the owner of the registration in this registry. May only be called by the owner of the registration.

Events

Name Migrated

This event is emitted when a name is migrated from the legacy registrar.

Name Registered

This event is emitted when a controller registers a new name.

Name Renewed

This event is emitted when a controller renews (extends the registration of) a name.

Transfer

Returns true if a name is available for registration. Takes into account not-yet-migrated registrations from the legacy registrar. Registrar controllers may impose more restrictions on registrations than this contract (for example, a minimum name length), so this function should not be used to check if a name can be registered by a user. To check if a name can be registered by a user, .

This function is part of .

They behave as specified in .

These functions manage approvals as documented in .

This event is emitted when registration is transferred to a new owner. This is distinct from the 's Transfer event, which records transfers of ownership of the LNS record.

function nameExpires(uint256 label) external view returns(uint);
function available(uint256 label) public view returns(bool);
uint public transferPeriodEnds;
mapping(address=>bool) public controllers;
function getApproved(uint256 tokenId) public view returns (address operator);
function isApprovedForAll(address owner, address operator) public view returns (bool);
function ownerOf(uint256 label) external view returns(address);
function transferFrom(address from, address to, uint256 tokenId) public;
function safeTransferFrom(address from, address to, uint256 tokenId) public;
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public;
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
function approve(address to, uint256 tokenId) public;
function setApprovalForAll(address operator, bool _approved) public;
function reclaim(uint256 label) external;
event NameMigrated(uint256 indexed hash, address indexed owner, uint expires);
event NameRegistered(uint256 indexed hash, address indexed owner, uint expires);
event NameRenewed(uint256 indexed hash, uint expires);
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
  1. Contract API Reference
  2. .bch Permanent Registrar

Registrar

Previous.bch Permanent RegistrarNextController
  • Names and Registrations
  • Read Operations
  • Get Name Expiry
  • Check Name Availability
  • Get Transfer Period End
  • Get Controller Status
  • Check Token Approval
  • Check All Tokens Approval
  • Get Name Owner
  • Write Operations
  • Transfer a Name
  • Approve Operator
  • Reclaim LNS Record
  • Events
  • Name Migrated
  • Name Registered
  • Name Renewed
  • Transfer
ERC721
ERC721
ERC721
LNS Registry
Source
controller
LNS registry
reclaim
check name availability via the controller