Domains AS NFT
When Domains .tomi registrar migrated in May 2022, the .tomi registrar became an ERC721 compliant non-fungible token contract, meaning that .tomi registrations can be transferred in the same fashion as other NFTs.
Deriving tokenId from Domains name
The tokenId of Domains name is simply the uint256 representation of the hash of the label (xyz
for xyz.tomi
).
In the example above,79233663829379634837589865448569342784712482819484549289560981379859480642508
is the tokenId of xyz.tomi
Deriving Domains name from tokenId
Unlike deriving tokenId, deriving Domains name from tokenId is not as easy. This is because all Domains 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 Domains smart contracts to return Domains name using tokenId.
Our recommended way is to query via https://thegraph.com Domains subgraph. The graph decodes the hash to name as it indexes. The example code to query is as follows.
If you prefer not to rely on a third party like TheGraph, the team open-sourced tdns-rainbow containing a link to the original dataset (6GB with 133 million entities) so that you can host your own Domains name decoding service.
Turning subdomain into NFT
Currently, all the subdomains nor non .tomi
domains are not NFT, unless the domain registrar itself supports NFT such as (dcl.tomi
, and .kred
). If you want to turn all subdomains which you own, you have to create a registrar
Create a registrar contract as ERC721 compliant
Set Domains 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
.tomi does not have .tokenURI
. However, we created a separate metadata service which NFT marketplaces like OpenSea can fetch metadata for tDNS such as registration data, expiration date, name length, etc. For more detail, please refer to the metadata documentation site.
Last updated