๐ŸŒดZNSRootRegistrar

Main entry point for the three main flows of ZNS - Register Root Domain, Reclaim and Revoke any domain.

This contract serves as the "umbrella" for many ZNS operations, it is given REGISTRAR_ROLE to combine multiple calls/operations between different modules to achieve atomic state changes and proper logic for the ZNS flows. You can see functions in other modules that are only allowed to be called by this contract to ensure proper management of ZNS data in multiple places. RRR - Register, Reclaim, Revoke start here and then call other modules to complete the flow. ZNSRootRegistrar.sol stores most of the other contract addresses and can communicate with other modules, but the relationship is one-sided, where other modules do not need to know about the ZNSRootRegistrar.sol, they only check REGISTRAR_ROLE that can, in theory, be assigned to any other address.

This contract is also called at the last stage of registering subdomains, since it has the common logic required to be performed for any level domains.

rootPricer

contract IZNSPricer rootPricer

treasury

contract IZNSTreasury treasury

domainToken

contract IZNSDomainToken domainToken

subRegistrar

contract IZNSSubRegistrar subRegistrar

constructor

constructor() public

initialize

function initialize(address accessController_, address registry_, address rootPricer_, address treasury_, address domainToken_) external

Create an instance of the ZNSRootRegistrar.sol for registering, reclaiming and revoking ZNS domains

Instead of direct assignments, we are calling the setter functions to apply Access Control and ensure only the ADMIN can set the addresses.

Parameters

registerRootDomain

function registerRootDomain(string name, address domainAddress, string tokenURI, struct IDistributionConfig.DistributionConfig distributionConfig, struct PaymentConfig paymentConfig) external returns (bytes32)

This function is the main entry point for the Register Root Domain flow. Registers a new root domain such as 0://wilder. Gets domain hash as a keccak256 hash of the domain label string casted to bytes32, checks existence of the domain in the registry and reverts if it exists. Calls ZNSTreasury to do the staking part, gets tokenId for the new token to be minted as domain hash casted to uint256, mints the token and sets the domain data in the ZNSRegistry and, possibly, ZNSAddressResolver. Emits a DomainRegistered event.

Parameters

coreRegister

function coreRegister(struct CoreRegisterArgs args) external

External function used by ZNSSubRegistrar for the final stage of registering subdomains.

Parameters

_coreRegister

function _coreRegister(struct CoreRegisterArgs args) internal

Internal function that is called by this contract to finalize the registration of a domain. This function as also called by the external coreRegister() function as a part of registration of subdomains. This function kicks off payment processing logic, mints the token, sets the domain data in the ZNSRegistry and fires a DomainRegistered event. For params see external coreRegister() docs.

_processPayment

function _processPayment(struct CoreRegisterArgs args) internal

Internal function that is called by this contract to finalize the payment for a domain. Once the specific case is determined and protocolFee calculated, it calls ZNSTreasury to perform transfers.

revokeDomain

function revokeDomain(bytes32 domainHash) external

This function is the main entry point for the Revoke flow. Revokes a domain such as 0://wilder. Gets tokenId from casted domain hash to uint256, calls ZNSDomainToken to burn the token, deletes the domain data from the ZNSRegistry and calls ZNSTreasury to unstake and withdraw funds user staked for the domain. Emits a DomainRevoked event.

Note that we are not clearing the data in ZNSAddressResolver as it is considered not necessary since none other contracts will have the domain data on them. If we are not clearing ZNSAddressResolver state slots, we are making the next Register transaction for the same name cheaper, since SSTORE on a non-zero slot costs 5k gas, while SSTORE on a zero slot costs 20k gas. If a user wants to clear his data from ZNSAddressResolver, he can call ZNSAddressResolver directly himself BEFORE he calls to revoke, otherwise, ZNSRegistry owner check will fail, since the owner there will be 0x0 address. Also note that in order to Revoke, a caller has to be the owner of both: Name (in ZNSRegistry) and Token (in ZNSDomainToken).

Parameters

_coreRevoke

function _coreRevoke(bytes32 domainHash, address owner) internal

Internal part of the revokeDomain(). Called by this contract to finalize the Revoke flow of all domains. It calls ZNSDomainToken to burn the token, deletes the domain data from the ZNSRegistry and calls ZNSTreasury to unstake and withdraw funds user staked for the domain. Also emits a DomainRevoked event.

reclaimDomain

function reclaimDomain(bytes32 domainHash) external

This function is the main entry point for the Reclaim flow. This flow is used to reclaim full ownership of a domain (through becoming the owner of the Name) from the ownership of the Token. This is used for different types of ownership transfers, such as:

  • domain sale - a user will sell the Token, then the new owner has to call this function to reclaim the Name

  • domain transfer - a user will transfer the Token, then the new owner has to call this function to reclaim the Name

A user needs to only be the owner of the Token to be able to Reclaim. Updates the domain owner in the ZNSRegistry to the owner of the token and emits a DomainReclaimed event.

isOwnerOf

function isOwnerOf(bytes32 domainHash, address candidate, enum IZNSRootRegistrar.OwnerOf ownerOf) public view returns (bool)

Function to validate that a given candidate is the owner of his Name, Token or both.

Parameters

setRegistry

function setRegistry(address registry_) public

Setter function for the ZNSRegistry address in state. Only ADMIN in ZNSAccessController can call this function.

Parameters

setRootPricer

function setRootPricer(address rootPricer_) public

Setter for the IZNSPricer type contract that Zero chooses to handle Root Domains. Only ADMIN in ZNSAccessController can call this function.

Parameters

setTreasury

function setTreasury(address treasury_) public

Setter function for the ZNSTreasury address in state. Only ADMIN in ZNSAccessController can call this function.

Parameters

setDomainToken

function setDomainToken(address domainToken_) public

Setter function for the ZNSDomainToken address in state. Only ADMIN in ZNSAccessController can call this function.

Parameters

setSubRegistrar

function setSubRegistrar(address subRegistrar_) external

Setter for ZNSSubRegistrar contract. Only ADMIN in ZNSAccessController can call this function.

Parameters

_authorizeUpgrade

function _authorizeUpgrade(address newImplementation) internal view

To use UUPS proxy we override this function and revert if msg.sender isn't authorized

Parameters

Last updated