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
- Host: GitHub
- URL: https://github.com/block-core/blockcore-dns-js
- Owner: block-core
- License: mit
- Created: 2022-07-20T16:18:50.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-04-22T19:20:01.000Z (about 2 years ago)
- Last Synced: 2025-04-19T03:23:00.109Z (about 1 year ago)
- Language: TypeScript
- Size: 57.6 KB
- Stars: 2
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
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();
```