Implementation & Architecture
Last updated
Last updated
Registry
Registry is a smart contract that contains a list of all domains. The higher-level domain owner can manage lower-level domain data. For example, “ust” domain owner (TNS registrar) can manage “alice.ust” domain by changing “alice.ust” owner. Each record in the resolver address indicates which address should be used to resolve TNS data.
The registry stores domain records using node hash as a key which is the same method as ENS.
Resolver
Resolver is a straightforward smart contract that stores key-value data of the domains including address, email, Twitter, avatar, etc. The most important responsibility of the resolver is to translate domain names to Terra addresses so that other smart contracts and dApps will be able to use readable domain names instead of Terra addresses. Only the owner of the name on the registry can modify the record of that name.
In order to retrieve a Terra address, users have 2 steps to do. First, ask the registry for the address of the resolver that is responsible for that name. Second, ask the resolver for the Terra address.
Registrar
Registrar is an NFT smart contract and the top-level domain “ust” owner on the registry. This contract stores the NFT image and expiration date of each TNS. When the new TNS is registered, the registrar will update the ownership of the registered name on the registry and mint a new NFT for that name. The NFT owner has permission to update the ownership of that name on the registry which means the NFT owner can let any address be an owner on the registry to manage data on the resolver (which is called “Editor” on TNS web app) and then the NFT owner can reclaim the ownership later.
The token ID of the NFT is a fixed-length string following ENS standard which can be calculated by applying “keccak256” on the label; the name without a top-level domain. For example, “alice.ust” domain will have “alice” as a label and the token ID for “alice.ust” will be keccak256( “alice” ) which is “9c0257114eb9399a2985f8e75dad7600c5d89fe3824ffa99ec1c3eb8bf3b0501”
Controller
Controller is a smart contract that is responsible for registration and renewing domains. This contract is the only contract that has permission to register on the registrar. When users register new domains, users have to call “register” on the controller and then the controller will handle other processes (such as minting NFT, setting ownership on the registry, transferring the NFT to the new owner, etc.) by interacting with the registrar internally.
Reverse record
Reverse record is a smart contract that allows you to replace the complicated address with your .ust account and make it function across a wide range of protocols.
The advantage of setting a reverse record is to transform a long, random, and unreadable terra address to your unique on-chain profile.