Crypto DNS

In our earlier tutorial we created a domain. So how we use it?

The easiest is to make a GET on the Unstoppable Domains API using the domain name as the parameter:

https://unstoppabledomains.com/api/v1/cryptocamtech.crypto

{
  "addresses": {
    "ETH": "0x24909aba725e36fefad16293e473b03f775e1123"
  },
  "whois": {
    "email": "cryptocamtech@gmail.com"
  },
  "ipfs": {
    "html": "QmWe4Bq5cBeU9peBpfCDL8gKV29pCSvLRL47mQaagDTFiE",
    "redirect_domain": "https://gateway.pinata.cloud/ipfs/QmWe4Bq5cBeU9peBpfCDL8gKV29pCSvLRL47mQaagDTFiE/"
  },
  "gundb": {},
  "meta": {
    "owner": "0x24909aba725e36fefad16293e473b03f775e1123",
    "type": "CNS",
    "ttl": 0
  }
}

We can also use the blockchain via the Unstoppable Domains library.

npm init -y
npm install --save @unstoppabledomains/resolution

Set up your project on Infura and write a script to find the details:

const {default: Resolution} = require('@unstoppabledomains/resolution')
;

const resolution = new Resolution({blockchain: {
    cns: {url: 'https://mainnet.infura.io/v3/<your project id>'}
  }})
;

const domain = 'cryptocamtech.crypto';

resolution.address(domain, "ETH")
      .then(address => console.log(domain + ' resolves to ' + address))
      .catch(console.error);

When run this shows:

cryptocamtech.crypto resolves to 0x24909aba725e36fefad16293e473b03f775e1123

You can also resolve an IPFS domain:

const publicIPFSgateway = 'https://cloudflare-ipfs.com/ipfs';
resolution.ipfsHash(domain).then(hash => console.log(`${publicIPFSgateway}/${hash}`));

Which then shows:

https://cloudflare-ipfs.com/ipfs/QmWe4Bq5cBeU9peBpfCDL8gKV29pCSvLRL47mQaagDTFiE

It’s all very simple. See here for more details. Enjoy!

Published by Crypto Cam Tech

Professional developer for 30 years + with the passion for helping others in their journey.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: