📝Namekit
Learn how to seamlessly integrate Decentraweb names for wallet addresses into your website or dApp with our Namekit
Our Namekit allows developers to integrate reading of Decentraweb Domain and ENS Domain Records allowing developers to utilise human-friendly domains against crypto wallet addresses
If you need to manage domain data/interact with our Smart Contracts you'll need to integrate our Core Library
View our NPM Package :
Domain Resolution Logic
Domain name provider is detected using following logic:
If domain name ends with
.eth
then it is resolved through ENSIf domain name TLD matches one of the ICANN TLDs, then it is resolved through regular DNS.
All other domains are resolved with DWEB contracts.
List of ICANN domains can be found here and is updated regularly.
Important Note: This logic may change in the future.
Installation
To install Decentraweb Namekit, run the following within your terminal to your project directory
Initialization
Namekit uses ethers.js to call Ethereum contracts. It is required as peer dependency.
Decentraweb supports both Ethereum and Polygon networks. Namekit will automatically detect which network to use based on where domain name is located currently. To initialize Namekit instance you need to pass Ethereum and Polygon network name (mainnet
is used with 'matic' and goerli
is used with 'maticmum') and ethers.js providers for each network
Alternatively, if you use one of supported providers, you can initialize Namekit in a simpler way:
Browser Bundle
In most cases importing library using npm
is preferred way, but for fast prototyping you can load it from our CDN:
Resolve Ethereum Address to Name
Ethereum address can be resolved through both Decentraweb and ENS contracts or through one specified system.
To query Decentraweb names only :
Resolve Name to Ethereum Address
In this case Namekit will detect which domain name system name belongs to and will look for Ethereum address associated with given name. Note that classic domains will always return null
.
Reading Extended Domain Data
By calling namekit.domain(domainName)
you can get instance of class that will allow to read extended data associated with domain name. Depending on domain name provider you will get either DWEBDomain
, ENSDomain
or ICANNDomain
instance. Below you can see feature support table for different domain name systems.
*supported through DNSLink
Domain Name
All domain name wrapper classes (DWEBDomain
, ENSDomain
and ICANNDomain
) have same interface to provide consistent API for developers.
Notes:
Full list of supported cryptocurrencies can be found in @ensdomains/address-encoder documentation.
Unsupported feature methods will always return
null
and won't throw an error.There is no reliable way to check if domain name is registered for classic DNS. Because of this
domain.exists()
will always returntrue
foricann
domains.DNS records are stored in binary format. This library uses dns-packet library to encode/decode data.
Last updated