Skip to content
Lattice

ENSSubnameIssuerLib

Git Source

Title: ENSSubnameIssuerLib

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from ENS (https://github.com/ensdomains/ens-contracts)

Library letting a diamond that owns a parent ENS name mint subnames via the ENS NameWrapper.

Three-layer pattern: this library holds the logic and namespaced storage; the stateless ENSSubnameIssuer facet forwards to it. A thin, role-gated wrapper over the canonical NameWrapper.setSubnodeRecord — it makes no assumptions about resolver authorization or token transfer. Setting the new subname's forward addr record is the new owner's job; the child sets its own reverse record via a future ENS reverse-record module.

Functions

ensSubnameIssuerStorage

function ensSubnameIssuerStorage() internal pure returns (ENSSubnameIssuerStorage storage $);

Returns

NameTypeDescription
$ENSSubnameIssuerStorage

__ENSSubnameIssuer_init

Initializes the ENSSubnameIssuer module with the NameWrapper to use.

Must be called inside a pre/postInitializer block. Reverts ENSSubnameIssuerZeroNameWrapper for a zero NameWrapper. Registers IENSSubnameIssuer for ERC-165.

function __ENSSubnameIssuer_init(address _nameWrapper) internal;

Parameters

NameTypeDescription
_nameWrapperaddressThe ENS NameWrapper for this chain.

registerInterface

Registers support for the IENSSubnameIssuer interface via ERC-165.

function registerInterface() internal;

issueSubname

Mints label.<parent> via the NameWrapper, owned by owner with resolver set.

Gated on ENS_SUBNAME_ISSUER_ROLE. The diamond must own/approve parentNode in the NameWrapper. The library makes no further calls (no addr-record write, no token transfer). See INameWrapper: verify the deployed setSubnodeRecord selector (0x24c1af44) on your target chain before mainnet use.

function issueSubname(
        bytes32 parentNode,
        string calldata label,
        address owner,
        address resolver,
        uint64 ttl,
        uint32 fuses,
        uint64 expiry
    ) internal returns (bytes32 node);

Parameters

NameTypeDescription
parentNodebytes32The parent name's node (wrapped + controlled by this diamond).
labelstringThe subname label.
owneraddressThe owner of the new subname.
resolveraddressThe resolver to set for the new subname.
ttluint64The TTL for the new subname.
fusesuint32The fuses to burn on the new subname.
expiryuint64The expiry timestamp for the new subname.

Returns

NameTypeDescription
nodebytes32The newly created subname's node.

setNameWrapper

Sets or rotates the NameWrapper.

Gated on ENS_SUBNAME_ISSUER_ROLE. Reverts ENSSubnameIssuerZeroNameWrapper for zero.

function setNameWrapper(address _nameWrapper) internal;

Parameters

NameTypeDescription
_nameWrapperaddressThe NameWrapper to use.

nameWrapper

Returns the configured NameWrapper.

function nameWrapper() internal view returns (address);

Returns

NameTypeDescription
<none>address