A library for interacting with blockchain domain names.
Supported domain zones:
Use the npm
or yarn
to install the resolution package.
yarn add @unstoppabledomains/resolution
npm install @unstoppabledomains/resolution --save
If you're interested in resolving domains via the command line, see CLI section.
Create a new project.
mkdir test-out-resolution && cd $_
yarn init -y
yarn add @unstoppabledomains/resolution
Make a file, script.js
.
const {default: Resolution} = require('@unstoppabledomains/resolution')
const resolution = new Resolution()
function resolve(domain, currency) {
resolution.address(domain, currency)
.then(address => console.log(domain, 'resolves to', address))
.catch(console.error)
}
resolve('brad.crypto', 'ETH')
resolve('brad.zil', 'ZIL')
Execute the script.
$ node script.js
brad.crypto resolves to 0x8aaD44321A86b170879d7A244c1e8d360c99DdA8
brad.zil resolves to zil1yu5u4hegy9v3xgluweg4en54zm8f8auwxu0xxj
Resolution library provides a way to resolve a domain name using a direct blockchain call. For this purpose there are two main methods to look for: ** Resolution.resolve ** and ** Resolution.address **
This method accept the domain name and returns following object or null in case of error
{
addresses: {}, // if domain will resolve to anything it will be here
meta: {
owner: null, // this means the domain is avalable for purchase
ttl: 0,
},
}
This method accepts two arguments:
It returns you the address if such exists or simply null if such address wasn't found. Beside the resolution there are also methods to test whether the domain is in valid format or supported by the network
Accepts domain name and returns boolean if such domain is supported by ens, .crypto, or .zil
Accepts the domain name and tests it against the current blockchain network specified in constructor of Resolution. It will also check if the domain is in valid format
If you want to use resolution CLI, install this package globally:
yarn global add @unstoppabledomains/resolution
npm install -g @unstoppabledomains/resolution
Once you have installed the CLI you can go ahead and use it without any extra configuration. By default the cli is using https://main-rpc.linkpool.io service as a gateway to blockchain. If you want to change it to some other providers including your own you can do so by utilizing resolution -C flag.
As an argument to -C type the following structure url:< https://.... >
Example of usage
resolution -C url:https://...
You can find all of the options for resolution cli within -h, --help flag.
Example:
resolution -mc eth,btc,DODGE,unknown -d brad.zil
When resolution hits an error it returns the error code instead of throwing. So if you see something like RECORD_NOT_FOUND you know exactly that record was not found for this query.
Use next commands for setting up development environment. (macOS Terminal or Linux shell).
Install NVM
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
Install concrete version of node.js
nvm install 12.12.0
Install yarn
npm install -g yarn
Clone repo
git clone https://github.com/unstoppabledomains/resolution.git
cd resolution
Install dependencies
yarn install
Generated using TypeDoc