๐Ÿ“™ZNSRegistry

The main reference data contract in ZNS. Also, often, the last contract in the call chain of many operations where the most crucial Name owner data settles. Owner of a domain in this contract also serves as the owner of the stake in ZNSTreasury.

resolvers

mapping(string => address) resolvers

records

mapping(bytes32 => struct IZNSRegistry.DomainRecord) records

Mapping of domainHash to DomainRecord struct to hold information about each domain

operators

mapping(address => mapping(address => bool)) operators

Mapping of owner => operator => bool to show accounts that are or aren't allowed access to domains that owner has access to. Note that operators can NOT change the owner of the domain, but can change the resolver or resolver records.

onlyOwnerOrOperator

modifier onlyOwnerOrOperator(bytes32 domainHash)

Revert if msg.sender is not the owner or an operator allowed by the owner

Parameters

onlyOwner

modifier onlyOwner(bytes32 domainHash)

Revert if msg.sender is not the owner. Used for owner restricted functions.

Parameters

constructor

constructor() public

initialize

function initialize(address accessController_) external

Initializer for the ZNSRegistry proxy.

! The owner of the 0x0 hash should be a multisig ideally, but EOA can be used to deploy !

Admin account deploying the contract will be the owner of the 0x0 hash !

Parameters

exists

function exists(bytes32 domainHash) external view returns (bool)

Checks if a given domain exists

Parameters

isOwnerOrOperator

function isOwnerOrOperator(bytes32 domainHash, address candidate) public view returns (bool)

Checks if provided address is an owner or an operator of the provided domain

Parameters

isOperatorFor

function isOperatorFor(address operator, address owner) external view returns (bool)

External function that checks if provided address is an operator for the provided owner.

Parameters

setOwnersOperator

function setOwnersOperator(address operator, bool allowed) external

Set an operator as allowed to give or remove permissions for ALL domains owned by the owner msg.sender. Emits an OperatorPermissionSet event.

Parameters

getDomainRecord

function getDomainRecord(bytes32 domainHash) external view returns (struct IZNSRegistry.DomainRecord)

Gets a record for a domain (owner, resolver) from the internal mapping records. records maps a domain hash to a DomainRecord struct.

Parameters

getDomainOwner

function getDomainOwner(bytes32 domainHash) external view returns (address)

Gets the owner of the given domain

Parameters

getDomainResolver

function getDomainResolver(bytes32 domainHash) external view returns (address)

Gets the resolver set for the given domain.

Parameters

createDomainRecord

function createDomainRecord(bytes32 domainHash, address owner, string resolverType) external

Creates a new domain record. Only callable by the ZNSRootRegistrar.sol or an address that has REGISTRAR_ROLE. This is one of the last calls in the Register flow that starts from ZNSRootRegistrar.registerRootDomain(). Calls 2 internal functions to set the owner and resolver of the domain separately. Can be called with resolver param as 0, which will exclude the call to set resolver. Emits DomainOwnerSet and possibly DomainResolverSet events.

Parameters

getResolverType

function getResolverType(string resolverType) public view returns (address)

Given a resolver type, returns the address of the resolver contract for that type or 0x0 if not found

Parameters

addResolverType

function addResolverType(string resolverType, address resolver) public

Add a new resolver type option to the mapping of types This function can also be used to update the resolver mapping for an existing resolver simple by using an existing key like "address" with a new address

Parameters

deleteResolverType

function deleteResolverType(string resolverType) public

Delete a resolver type from the mapping of types

Parameters

updateDomainRecord

function updateDomainRecord(bytes32 domainHash, address owner, string resolverType) external

Updates an existing domain record's owner and resolver. Note that this function can ONLY be called by the Name owner of the domain. This is NOT used by the ZNSRootRegistrar.sol contract and serves as a user facing function for the owners of existing domains to change their data on this contract. A domain operator can NOT call this, since he is not allowed to change the owner. Emits DomainOwnerSet and DomainResolverSet events.

Parameters

updateDomainOwner

function updateDomainOwner(bytes32 domainHash, address owner) external

Updates the owner of an existing domain. Can be called by either the Name owner on this contract OR the ZNSRootRegistrar.sol contract as part of the Reclaim flow that starts at ZNSRootRegistrar.sol.reclaim(). Emits an DomainOwnerSet event.

Parameters

updateDomainResolver

function updateDomainResolver(bytes32 domainHash, string resolverType) external

Updates the resolver of an existing domain in records. Can be called by either the owner of the Name or an allowed operator.

Parameters

deleteRecord

function deleteRecord(bytes32 domainHash) external

Deletes a domain's record from this contract's state. This can ONLY be called by the ZNSRootRegistrar.sol contract as part of the Revoke flow or any address holding the REGISTRAR_ROLE. Emits a DomainRecordDeleted event.

Parameters

_exists

function _exists(bytes32 domainHash) internal view returns (bool)

Check if a domain exists. True if the owner is not 0x0

Parameters

_setDomainOwner

function _setDomainOwner(bytes32 domainHash, address owner) internal

Internal function to set a domain's owner in state records. Owner can NOT be set to 0, since we use delete operation as part of the deleteRecord() function. Emits a DomainOwnerSet event.

Parameters

_setDomainResolver

function _setDomainResolver(bytes32 domainHash, string resolverType) internal

Internal function to set a domain's resolver in state records. Resolver can be set to 0, since we allow partial domain data. Emits a DomainResolverSet event.

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