Resolve D3 Names
Building With DNS Connect SDK
Overview
The DNS Connect SDK aims to bring different Web3 Name Resolution services under one umbrella to simplify integration efforts for developers. It supports the following resolution methods, which can be applied in order of priority:
DNS Resolution
(Optional) ENS resolution
(Optional) Other resolution services - either provided by D3 or community.
Why Use DNS Connect SDK
DNS Connect SDK offers a host of benefits including:
Seamless transition between existing web (Internet) and Web3 infrastructure
Futureproof design with backward and forward compatibility at its foundation
Single integration without the need for endless SDKs, APIs and more
Accessible, compliant and secure infrastructure
SDK Documentation and Sample Code
DNS Connect is a unified JavaScript SDK to resolve Web3 names, built to be modular in nature and consisting of several resolution modules, which are applied in order of priority:
DNS resolution module. Resolves Web3 names using DNS TXT records. This is a core module, which cannot be disabled and always applied first.
ENS resolution module. Resolves Web3 names using ENS. Distributed as a separate
@webinterop/dns-connect-enspackage.Other modules...
DNS Connect SDK can be used in both NodeJS and browser environments:
Node 18+ (
fetchapi support is needed, this might be relaxed in future).Browsers with ES2022 features support (basically all modern browsers).
@webinterop/dns-connect
@webinterop/dns-connectThis package provides a modular SDK itself and a DNS resolution module. It is a lightweight zero-dependency library, which can be used to perform basic Web3 Wallet address resolution using standard DNS protocol.
The SDK provides two methods for performing forward and reverse name resolution:
A basic example is shown below:
Our SDK is highly configurable, and can be customized for a variety of use cases:
Below is the list of supported Blockchain networks (passed as the second parameter to the resolve and reverseResolve methods):
Ethereum
ETH
Bitcoin
BTC
Shibarium
BONE
Core
CORE
Viction
VIC
Polygon
MATIC
Cardano
ADA
ApeChain
APE
Current version limitations:
IDNA (Unicode) names resolution is not supported, names should be normalized and converted to Punycode before passing to SDK.
Retries are not implemented for DNS queries.
Need to provide a common interface to pass cross-cutting services (caching, logging) to the modules.
logLevelis not respected for external logger. Need to use an internal logging abstraction.networkargument is not properly validated. SLIP44 validation can be added.
@webinterop/dns-connect-ens
@webinterop/dns-connect-ensThis is an optional module which adds support for ENS names resolution.
Basic usage:
Under the hood, it uses the @ensdomains/ensjs package, which in turn uses viem for blockchain integration. Viem chain and transport can be provided to further customize this module:
Current version limitations:
ENS TTL is currently not used, so resolution results are not cached. Internal
@ensdomains/ensjsis used instead.Provided
networkis not validated for support by@ensdomains/ensjs.
Custom resolution modules
Custom resolution modules can be written by implementing the DNSConnectModule interface:
To use it, pass it as a module in DNSConnect options:
Integrate using Resolver Smart Contract (CCIP Read)
DNS Connect provides CCIP Read-compatible Resolver smart contracts to support secure name resolution using standard web3 libraries. CCIP Read will perform an offchain lookup through a Gateway which implements DNS Connect SDK to resolve the name or address.
The following methods are available in the Resolver smart contracts to handle forward and reverse name resolution.
Any client that support CCIP Read can be used to interact with these smart contract methods. For example:
Blockchain explorers
Example resolving a name using ethers.js:
Below is the list of Resolver contract addresses on Mainnet and Testnet
Last updated