npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mcns

v1.0.0

Published

Multi-Chain Name Service - Resolve blockchain addresses from DNS TXT records

Downloads

98

Readme

MCNS - Multi-Chain Name Service

npm version License: MIT GitHub

A lightweight JavaScript/TypeScript library for resolving blockchain addresses from DNS TXT records. MCNS enables domain owners to publish their cryptocurrency addresses using simple DNS records, making it easy to send crypto to human-readable addresses.

Features

  • Simple DNS-based resolution - No blockchain queries needed, just DNS
  • Multi-chain support - Works with any blockchain (Ethereum, Bitcoin, MultiversX, Sui, etc.)
  • User-specific addresses - Support for blockchain.username.domain format
  • Email-like syntax - Resolve addresses using [email protected] format
  • Lightweight - Only one dependency (axios)
  • TypeScript support - Full type definitions included
  • Customizable - Configure DNS resolver and timeout

Installation

npm install mcns

Quick Start

import { getChainAddress, resolveAddress } from 'mcns';

// Resolve an Ethereum address for a domain
const ethAddress = await getChainAddress('ethereum', 'example.com');

// Resolve using email-like format
const btcAddress = await resolveAddress('[email protected]');

// Resolve a user-specific address
const userAddress = await resolveAddress('[email protected]');

How It Works

MCNS queries DNS TXT records in a specific format to retrieve blockchain addresses:

| Format | DNS Query | Use Case | |--------|-----------|----------| | blockchain.domain | ethereum.example.com | Domain-level address | | blockchain.username.domain | bitcoin.alice.example.com | User-specific address |

Setting Up DNS Records

Add TXT records to your domain's DNS configuration:

ethereum.example.com     TXT    "0x742d35Cc6634C0532925a3b844Bc9e7595f..."
bitcoin.example.com      TXT    "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq"
bitcoin.alice.example.com TXT   "bc1qaliceaddress..."

API Reference

getChainAddress(blockchain, domain, [username], [options])

Resolves a blockchain address from a DNS TXT record.

Parameters:

  • blockchain (string) - The blockchain name (e.g., 'ethereum', 'bitcoin')
  • domain (string) - The domain name (e.g., 'example.com')
  • username (string, optional) - Username for user-specific addresses
  • options (object, optional):
    • dnsResolver (string) - DNS-over-HTTPS resolver URL (default: 'https://dns.google/resolve')
    • timeout (number) - Request timeout in milliseconds (default: 5000)

Returns: Promise<string> - The blockchain address

// Domain-level address
const address = await getChainAddress('ethereum', 'example.com');

// User-specific address
const userAddress = await getChainAddress('bitcoin', 'example.com', 'alice');

// With custom options
const address = await getChainAddress('ethereum', 'example.com', {
  timeout: 10000,
  dnsResolver: 'https://cloudflare-dns.com/dns-query'
});

resolveAddress(address, [options])

Resolves a blockchain address using email-like format.

Parameters:

Returns: Promise<string> - The blockchain address

// Domain-level
const address = await resolveAddress('[email protected]');

// User-specific
const userAddress = await resolveAddress('[email protected]');

getMultipleChainAddresses(queries, [options])

Resolves multiple blockchain addresses in parallel.

Parameters:

  • queries (Array) - Array of { blockchain, domain, username? } objects
  • options (object, optional) - Same as getChainAddress

Returns: Promise<Record<string, string>> - Map of addresses keyed by full query name

const addresses = await getMultipleChainAddresses([
  { blockchain: 'ethereum', domain: 'example.com' },
  { blockchain: 'bitcoin', domain: 'example.com' },
  { blockchain: 'bitcoin', domain: 'example.com', username: 'alice' }
]);

// Result:
// {
//   'ethereum.example.com': '0x...',
//   'bitcoin.example.com': 'bc1q...',
//   'bitcoin.alice.example.com': 'bc1q...'
// }

Error Handling

import { getChainAddress } from 'mcns';

try {
  const address = await getChainAddress('ethereum', 'example.com');
  console.log(address);
} catch (error) {
  if (error.message.includes('No TXT record found')) {
    console.error('DNS record does not exist');
  } else if (error.message.includes('timeout')) {
    console.error('DNS lookup timed out');
  } else if (error.message.includes('Invalid address format')) {
    console.error('Invalid email-like address format');
  } else {
    console.error('Error:', error.message);
  }
}

Using Alternative DNS Resolvers

By default, MCNS uses Google's DNS-over-HTTPS service. You can use other resolvers:

// Cloudflare DNS
const address = await getChainAddress('ethereum', 'example.com', {
  dnsResolver: 'https://cloudflare-dns.com/dns-query'
});

TypeScript

Full TypeScript support with exported types:

import {
  getChainAddress,
  resolveAddress,
  getMultipleChainAddresses,
  GetChainAddressOptions
} from 'mcns';

const options: GetChainAddressOptions = {
  timeout: 10000,
  dnsResolver: 'https://dns.google/resolve'
};

const address: string = await getChainAddress('ethereum', 'example.com', options);

License

MIT