PNS as NFT
When PNS .pls registrar became an ERC721 compliant non-fungible token contract, meaning that .pls registrations can be transferred in the same fashion as other NFTs.
Deriving tokenId from PNS name
The tokenId of PNS name is simply the uint256 representation of the hash of the label (pns
for pns.pls
).
In the example above, 26004363047961302715841817009868885426915362095607813844703532662233080456292 is the tokenId of pns.pls
Deriving PNS name from tokenId
Unlike deriving tokenId, deriving PNS name from tokenId is not as easy. This is because all PNS names are stored as fixed-length hash to allow registering infinite length of names. The downside of this architecture is that you cannot directly query PNS smart contracts to return PNS name using tokenId.
Our recommended way is to query via PNS subgraph. The graph decodes the hash to name as it indexes. The example code to query is as follows.
Turning subdomain into NFT
Currently, all the subdomains nor non .pls
domains are not NFT. If you want to turn all subdomains which you own, you have to create a registrar
Create a registrar contract as ERC721 compliant
Set PNS registry address (mostly when you deploy the registrar)
Create
register
function which callsregistry.setSubnodeOwner
then mint the token making the subdomain label hash as tokenId
Once deployed, then you have to transfer the controller address to the contract.
For non-technical users, we are currently working on upgrading our SubdomainRegistrar
which allows you to turn your subdomain into NFT without any coding.
Metadata
.pls does not have .tokenURI
. However, we created a separate metadata service which NFT marketplaces like OpenSea can fetch metadata for PNS such as registration data, expiration date, name length, etc. For more detail, please refer to the metadata documentation site.
Last updated