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!