Skip to content

Latest commit

 

History

History
109 lines (79 loc) · 2.62 KB

NameWrapper.md

File metadata and controls

109 lines (79 loc) · 2.62 KB

NameWrapper

NameWrapper is ENS new imported contract. it can be used a wrap a domain name as 1155 NFT. When a domain is wrapped, domain owner need to invoke NameWrapper's method to manage domain config for example resolver, ttl, subRecord.

For more info about NameWrapper, please refer to NameWrapper, and this introduction - ENS Name Wrapper: Features, Benefits & Possibilities in Web3

NameWrapper is compatible with 1155 API, which means wrapped names are ERC1155 tokens. In addition to implementing ERC1155, wrapped names have an ERC721-compatible ownerOf function to return the owner of a wrapped name.

NOTE: A name's 1155 tokenId in NameWrapper is the the namehash of the complete name.

const namehash = require('eth-ens-namehash');
const name = 'domain.web3';
const tokenId = namehash.hash(name);

NameWrapper contract API

wrap/unwrap

To wrap or unwrap a name, check this introduction

Related methods:

  • wrapETH2LD
  • unwrapETH2LD
  • registerAndWrapETH2LD
  • wrap
  • unwrap

Currently if one buy a CNS name, it will automatically wrap the name.

CNS Operations

renew

function renew(
        uint256 tokenId,
        uint256 duration,
        uint32 fuses,
        uint64 expiry
) external override onlyController returns (uint256 expires);

setSubnodeOwner

function setSubnodeOwner(
    bytes32 parentNode,
    string calldata label,
    address owner,
    uint32 fuses,
    uint64 expiry
)

setSubnodeRecord

function setSubnodeRecord(
    bytes32 parentNode,
    string memory label,
    address owner,
    address resolver,
    uint64 ttl,
    uint32 fuses,
    uint64 expiry
)

setRecord

function setRecord(
    bytes32 node,
    address owner,
    address resolver,
    uint64 ttl
)

setResolver

function setResolver(bytes32 node, address resolver)

setTTL

function setTTL(bytes32 node, uint64 ttl)

userDomains

This method can return all domains owned by an address.

function userDomains(address user) public view returns (string[] memory);

The returned domains is encoded as DNS Name Notation and Message Compression Technique

1155 methods

  • setApprovalForAll
  • balanceOf
  • safeTransferFrom