Smart Contracts
Contracts
SldRegistrationManager

SldRegistrationManager

Git Source (opens in a new tab)

Author: Sam Ward

Inherits: OwnableUpgradeable, ISldRegistrationManager, PaymentManager, HasUsdOracle, HasLabelValidator

Author: hodl.esf.eth

Registration manager for second level domains

State Variables

sldRegistrationHistory

mapping(bytes32 => SldRegistrationDetail) public sldRegistrationHistory;

pricesAtRegistration

mapping(bytes32 => uint80[10]) public pricesAtRegistration;

addressDiscounts

mapping(bytes32 => mapping(address => SldDiscountSettings)) public addressDiscounts;

globalStrategy

IGlobalRegistrationRules public globalStrategy;

sld

IHandshakeSld public sld;

tld

IHandshakeTld public tld;

commitIntent

ICommitIntent public commitIntent;

Functions

constructor

constructor();

init

Initialize the contract

This function is called during contract deployment and sets up the contract's dependencies. It should only be called once.

function init(
    IHandshakeTld _tld,
    IHandshakeSld _sld,
    ICommitIntent _commitIntent,
    IPriceOracle _oracle,
    ILabelValidator _validator,
    IGlobalRegistrationRules _globalRules,
    address _payoutWallet,
    address _owner
) public initializer;

Parameters

NameTypeDescription
_tldIHandshakeTldAddress of the top level domain contract
_sldIHandshakeSldAddress of the second level domain contract
_commitIntentICommitIntentAddress of the commit intent contract
_oracleIPriceOracleAddress of the price oracle contract
_validatorILabelValidatorAddress of the label validator contract
_globalRulesIGlobalRegistrationRulesAddress of the global registration rules contract
_payoutWalletaddressAddress of the wallet for royalties
_owneraddressAddress of the contract owner

registerSld

Register an eligible Sld. Require to send in the appropriate amount of ethereum

Checks commitIntent, labelValidator, globalStrategy to ensure domain can be registered

function registerSld(
    string calldata _label,
    bytes32 _secret,
    uint256 _registrationLength,
    bytes32 _parentNamehash,
    address _recipient
) external payable;

Parameters

NameTypeDescription
_labelstringselected SLD label. Requires to pass LabelValidator validation
_secretbytes32This is the secret generated from the commitIntent contract
_registrationLengthuint256Number of days for registration length
_parentNamehashbytes32bytes32 representation of the top level domain
_recipientaddressAddress that the sld should be sent to. address(0) will send to msg.sender

setAddressDiscounts

function setAddressDiscounts(
    bytes32 _parentNamehash,
    address[] calldata _addresses,
    SldDiscountSettings[] calldata _discounts
) public;

renewSld

Renew an eligible Sld. Require to send in the appropriate amount of ethereum. Anyone can renew a domain, it doesn't have to be the owner of the SLD.

We check the historic values of what the domain was sold for originally.

function renewSld(string calldata _label, bytes32 _parentNamehash, uint80 _registrationLength) external payable;

Parameters

NameTypeDescription
_labelstringselected SLD label.
_parentNamehashbytes32bytes32 representation of the top level domain
_registrationLengthuint80Number of days for registration length

canRegister

function canRegister(bytes32 _namehash) private view returns (bool);

updateLabelValidator

Update the label validator contract. This just contains a function that checks the label is acceptable

This should implement the ILabelValidator interface. Can only be run from the contract owner wallet

function updateLabelValidator(ILabelValidator _validator) public onlyOwner;

Parameters

NameTypeDescription
_validatorILabelValidatorAddress of the label validator. This can be updated in the future if required.

updatePaymentAddress

Update the handshake payment address that primary funds are sent to

This function can only be run by the contract owner

function updatePaymentAddress(address _addr) public onlyOwner;

Parameters

NameTypeDescription
_addraddressWallet address to set the commission payment for primary sales to

updatePaymentPercent

Update the handshake payment percent that primary funds are sent to

This function can only be run by the contract owner

function updatePaymentPercent(uint256 _percent) public onlyOwner;

Parameters

NameTypeDescription
_percentuint256% of primary sales to send to the handshake wallet

updateGlobalRegistrationStrategy

Update the global registration strategy. As people can implement their own rules per TLD then this is to make sure that base rules cannot be updated by the TLD owners. $1 minimum etc.

This should implement the IGlobalRegistrationRules interface. Can only be run from the contract owner wallet

function updateGlobalRegistrationStrategy(IGlobalRegistrationRules _strategy) public onlyOwner;

Parameters

NameTypeDescription
_strategyIGlobalRegistrationRulesAddress of the global strategy. This should implement the IGlobalRegistrationRules interface.

updatePriceOracle

Update the chainlink price oracle.

Probably should never need updating.

function updatePriceOracle(IPriceOracle _oracle) public onlyOwner;

Parameters

NameTypeDescription
_oracleIPriceOracleAddress of the internal price oracle (this proxies to chainlink in current instance)

getTenYearGuarenteedPricing

When a domain is registered the 10 year pricing is saved to prevent an owner updating their TLD price strategy and then gouging the price for a popular domain.

function getTenYearGuarenteedPricing(bytes32 _sldNamehash) external view returns (uint80[10] memory _history);

Parameters

NameTypeDescription
_sldNamehashbytes32bytes32 representation of the SLD

Returns

NameTypeDescription
_historyuint80[10]An array containing the 10 year prices that were locked in when the domain was first registered

addRegistrationDetails

function addRegistrationDetails(
    bytes32 _namehash,
    ISldRegistrationStrategy _strategy,
    bytes32 _parentNamehash,
    string calldata _label
) private;

getRenewalPrice

When a domain is registered the 10 year pricing is saved. This function will return back the cheapest option for the renewer based on historic prices and the current strategy.

function getRenewalPrice(address _addr, bytes32 _parentNamehash, string calldata _label, uint256 _registrationLength)
    public
    view
    returns (uint256 _price);

Parameters

NameTypeDescription
_addraddress
_parentNamehashbytes32bytes32 representation of the top level domain
_labelstringLabel of the SLD
_registrationLengthuint256Registration length in days

Returns

NameTypeDescription
_priceuint256Returns the price in dollars (18 decimal precision)

safeCallRegistrationStrategyInAssembly

Calls the specified registration strategy contract and calculates the price used to prevent "gas griefing" attacks as the TLD owner can update the registration strategy

function safeCallRegistrationStrategyInAssembly(address _strategy, bytes memory _data, uint256 _registrationDays)
    private
    view
    returns (uint256 _price);

Parameters

NameTypeDescription
_strategyaddressThe address of the registration strategy contract
_databytesThe data to pass to the registration strategy contract
_registrationDaysuint256The number of days for which the domain will be registered

Returns

NameTypeDescription
_priceuint256The calculated price

getRegistrationBasePrice

function getRegistrationBasePrice(
    address _strategy,
    address _addr,
    bytes32 _parentNamehash,
    string calldata _label,
    uint256 _registrationLength,
    bool _isRenewal
) public view returns (uint256);

getRegistrationPrice

function getRegistrationPrice(
    address _strategy,
    address _addr,
    bytes32 _parentNamehash,
    string calldata _label,
    uint256 _registrationLength
) public view returns (uint256);

getCurrentDiscount

function getCurrentDiscount(bytes32 _parentNamehash, address _addr, bool _isRegistration)
    private
    view
    returns (uint256);

getRenewalPricePerDay

Gets the full registration cost and then divides it by the number of days to get the price per day.

function getRenewalPricePerDay(
    address _addr,
    bytes32 _parentNamehash,
    string calldata _label,
    uint256 _registrationLength
) public view returns (uint256 _price);

Parameters

NameTypeDescription
_addraddressAddress of the owner of the domain.
_parentNamehashbytes32Namehash of the parent domain.
_labelstringLabel of the domain.
_registrationLengthuint256Length of the registration.

Returns

NameTypeDescription
_priceuint256The renewal price per day for the domain.

getWeiValueOfDollar

function getWeiValueOfDollar() public view returns (uint256);

Events

DiscountSet

event DiscountSet(bytes32 indexed _tokenNamehash, address indexed _claimant, SldDiscountSettings _discount);