Smart Contracts
Contracts
HandshakeSld

HandshakeSld

Git Source (opens in a new tab)

Author: Sam Ward

Inherits: HandshakeNft, IHandshakeSld

Author: Sam Ward

erc721 SLD contract

State Variables

namehashToLabelMap

mapping(bytes32 => string) public namehashToLabelMap;

royaltyPayoutAmountMap

mapping(bytes32 => uint256) public royaltyPayoutAmountMap;

royaltyPayoutAddressMap

mapping(bytes32 => mapping(address => address)) public royaltyPayoutAddressMap;

namehashToParentMap

mapping(bytes32 => bytes32) public namehashToParentMap;

handshakeTldContract

IHandshakeTld public handshakeTldContract;

contractRegistrationStrategy

IGlobalRegistrationRules public contractRegistrationStrategy;

registrationManager

ISldRegistrationManager public registrationManager;

Functions

constructor

constructor(IHandshakeTld _tld) HandshakeNft("SLD", "Handshake SLD");

registerSld

Register and mint SLD NFT

This function can only be called by the registration manager contract

function registerSld(address _to, bytes32 _tldNamehash, string calldata _label)
    external
    payable
    isRegistrationManager;

Parameters

NameTypeDescription
_toaddressThe address that the SLD will be minted to. Zero address will be minted to msg.sender
_tldNamehashbytes32The bytes32 representation of the TLD
_labelstringThe label of the SLD

isApprovedOrOwner

Register and mint SLD NFT

This function is custom owner/approved checking function.

function isApprovedOrOwner(address _operator, uint256 _tokenId)
    public
    view
    override(HandshakeNft, IHandshakeSld)
    returns (bool _allowed);

Parameters

NameTypeDescription
_operatoraddressThe address that is being checked
_tokenIduint256The token ID of the SLD NFT to be checked

Returns

NameTypeDescription
_allowedboolIs the address the owner or on the accepted list

ownerOf

Check the owner of a specified token.

This function returns back the owner of an NFT. Will revert if the token does not exist or has expired.

function ownerOf(uint256 _tokenId) public view override(HandshakeNft, IHandshakeSld) returns (address _addr);

Parameters

NameTypeDescription
_tokenIduint256The token ID of the SLD NFT to be checked

Returns

NameTypeDescription
_addraddressOwner of NFT

hasExpired

function hasExpired(bytes32 _sldNamehash) private view returns (bool _hasExpired);

getRegistrationStrategy

Get the registration strategy for a TLD

This function gets the registration strategy of a top level domain. Will revert if the strategy is not set.

function getRegistrationStrategy(bytes32 _parentNamehash) public view returns (ISldRegistrationStrategy _strategy);

Parameters

NameTypeDescription
_parentNamehashbytes32Bytes32 representation of the top level domain

Returns

NameTypeDescription
_strategyISldRegistrationStrategyLinked registration strategy to the top level domain

setRegistrationManager

function setRegistrationManager(ISldRegistrationManager _registrationManager) public onlyOwner;

setRoyaltyPayoutAmount

Set the % royalty amount

This function sets the royalty percentage for EIP-2981 function. This function can only be run by the owner of the top level domain.

function setRoyaltyPayoutAmount(uint256 _id, uint256 _amount) public onlyParentApprovedOrOwner(_id);

Parameters

NameTypeDescription
_iduint256uint256 representation of the top level domain
_amountuint256Percentage to be set. Should be between 1-10%.

setRoyaltyPayoutAddress

Set the royalty payout address. This defaults to the owner of the top level domain in the first instance.

This function sets the royalty payout wallet for EIP-2981 function. This function can only be run by the owner of the top level domain.

function setRoyaltyPayoutAddress(uint256 _id, address _addr) public onlyParentApprovedOrOwner(_id);

Parameters

NameTypeDescription
_iduint256uint256 representation of the top level domain
_addraddressAddress to be set for the on-chain royalties to be sent to.

getSingleSldDetails

function getSingleSldDetails(address _recipient, uint256 _parentId, string calldata _label, uint256 _registrationLength)
    private
    view
    returns (SldDetail memory);

getSldDetails

Get multiple SLD details, which includes the price and NFT details

Input arrays should all be the same length.

function getSldDetails(
    address[] calldata _recipients,
    uint256[] calldata _parentIds,
    string[] calldata _labels,
    uint256[] calldata _registrationLengths
) external view returns (SldDetail[] memory _details);

Parameters

NameTypeDescription
_recipientsaddress[]Array of the recipients. Generally will just be the same address.
_parentIdsuint256[]Array of the parent IDs
_labelsstring[]Array of the SLD labels to be queried.
_registrationLengthsuint256[]Array of the length of registration (days)

Returns

NameTypeDescription
_detailsSldDetail[]_details

name

Gets the fully qualified domain name including TLD

This function will get the full domain name sld.tld. It will revert if the domain does not exist.

function name(bytes32 _sldNamehash)
    external
    view
    override(HandshakeNft, IHandshakeSld)
    returns (string memory _fullDomain);

Parameters

NameTypeDescription
_sldNamehashbytes32bytes32 representation of the sub domain

Returns

NameTypeDescription
_fullDomainstring_fullDomain

parent

function parent(bytes32 _sldNamehash)
    external
    view
    override(HandshakeNft, IHandshakeSld)
    returns (string memory _parentName);

expiry

function expiry(bytes32 _namehash) external view override(HandshakeNft, IHandshakeSld) returns (uint256 _expiry);

exists

function exists(uint256 tokenId) public view override returns (bool);

royaltyInfo

Gets the royalty information for a SLD

This function will get EIP-2981 royalty information based on the TLD

function royaltyInfo(uint256 tokenId, uint256 salePrice)
    external
    view
    returns (address receiver, uint256 royaltyAmount);

Parameters

NameTypeDescription
tokenIduint256uint256 representation of the SLD
salePriceuint256this does not link to any specific currency

onlyParentApprovedOrOwner

modifier onlyParentApprovedOrOwner(uint256 _id);

isRegistrationManager

modifier isRegistrationManager();