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
Name | Type | Description |
---|---|---|
_to | address | The address that the SLD will be minted to. Zero address will be minted to msg.sender |
_tldNamehash | bytes32 | The bytes32 representation of the TLD |
_label | string | The 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
Name | Type | Description |
---|---|---|
_operator | address | The address that is being checked |
_tokenId | uint256 | The token ID of the SLD NFT to be checked |
Returns
Name | Type | Description |
---|---|---|
_allowed | bool | Is 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
Name | Type | Description |
---|---|---|
_tokenId | uint256 | The token ID of the SLD NFT to be checked |
Returns
Name | Type | Description |
---|---|---|
_addr | address | Owner 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
Name | Type | Description |
---|---|---|
_parentNamehash | bytes32 | Bytes32 representation of the top level domain |
Returns
Name | Type | Description |
---|---|---|
_strategy | ISldRegistrationStrategy | Linked 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
Name | Type | Description |
---|---|---|
_id | uint256 | uint256 representation of the top level domain |
_amount | uint256 | Percentage 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
Name | Type | Description |
---|---|---|
_id | uint256 | uint256 representation of the top level domain |
_addr | address | Address 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
Name | Type | Description |
---|---|---|
_recipients | address[] | Array of the recipients. Generally will just be the same address. |
_parentIds | uint256[] | Array of the parent IDs |
_labels | string[] | Array of the SLD labels to be queried. |
_registrationLengths | uint256[] | Array of the length of registration (days) |
Returns
Name | Type | Description |
---|---|---|
_details | SldDetail[] | _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
Name | Type | Description |
---|---|---|
_sldNamehash | bytes32 | bytes32 representation of the sub domain |
Returns
Name | Type | Description |
---|---|---|
_fullDomain | string | _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
Name | Type | Description |
---|---|---|
tokenId | uint256 | uint256 representation of the SLD |
salePrice | uint256 | this does not link to any specific currency |
onlyParentApprovedOrOwner
modifier onlyParentApprovedOrOwner(uint256 _id);
isRegistrationManager
modifier isRegistrationManager();