An open API service indexing awesome lists of open source software.

https://github.com/block-core/blockcore-dns-js

JavaScript package to query and resolve dynamic and decentralized DNS entries
https://github.com/block-core/blockcore-dns-js

Last synced: about 1 year ago
JSON representation

JavaScript package to query and resolve dynamic and decentralized DNS entries

Awesome Lists containing this project

README

          



Blockcore



Blockcore DNS Provider



DNS Provider package to query and resolve dynamic and decentralized DNS entries





Work-in-Progress - use with caution!

# Blockcore DNS Provider

## Install

```sh
npm install @blockcore/dns
```

**Warning:** This package is native [ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) and does not provide a CommonJS export. If your project uses CommonJS, you'll have to [convert to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) or use the [dynamic `import()`](https://v8.dev/features/dynamic-import) function.

## Usage

```ts
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:

```ts
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: 'post@blockcore.net' });
let indexers = await dns.getServicesByType('Indexer');
```

You can create an load the nameservers using this static function:

```ts
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();
```