@blockcore/dns
v0.0.13
Published
DNS Provider package to query and resolve dynamic and decentralized DNS entries
Downloads
77
Readme
Blockcore DNS Provider
Install
npm install @blockcore/dns
Warning: This package is native ESM and does not provide a CommonJS export. If your project uses CommonJS, you'll have to convert to ESM or use the dynamic import()
function.
Usage
import { BlockcoreDns } from '@blockcore/dns';
let dns = new BlockcoreDns();
// This relies on a central nameserver registry:
await dns.load();
let indexers = await dns.getServicesByType('Indexer');
Get servers from known nameservers:
import { BlockcoreDns } from '@blockcore/dns';
let dns = new BlockcoreDns();
// This relies on fixed set of nameservers:
await dns.load({ url: 'https://ns.blockcore.net', contact: '[email protected]' });
let indexers = await dns.getServicesByType('Indexer');
You can create an load the nameservers using this static function:
let dnsServers = await BlockcoreDns.getDnsServers();
dns.setActiveServer(dnsServers[0].url);
await dns.api.getServicesByType('Indexer');
await dns.api.getServicesByNetwork('CITY');
await dns.api.getServicesByTypeAndNetwork('Indexer', 'CITY');
await dns.api.getExternalIP();