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

@xid/domain-resolver

v0.0.9

Published

ENS-like domain to address and reverse resolver utilities

Readme

@xid/domain-resolver

ENS 风格的域名解析/反向解析工具函数(支持批量多币种地址解析)。

安装

pnpm add @xid/domain-resolver
# 或
npm i @xid/domain-resolver

快速开始

import {
  resolveDomainToAddress,
  reverseResolveAddressToName,
  resolveDomainToAddresses
} from '@xid/domain-resolver';

// 通过 chainId 选择网络
const chainId = 33772211; // 例如某测试链

// 1) 域名 → 地址
const addr = await resolveDomainToAddress('your-domain.xone', chainId);

// 2) 地址 → 域名(前向验证)
const name = await reverseResolveAddressToName(
  '0xYourAddress',
  chainId,
  true
);

// 3) 域名 → 多币种地址(默认 12 个 coinTypes;只返回非空结果)
const multi = await resolveDomainToAddresses('your-domain.xone', chainId);

API 参考

resolveDomainToAddress

将域名解析为链上地址。

函数签名:

resolveDomainToAddress(name: string, chainId: number): Promise<string | null>

参数:

  • name: 要解析的域名(如 your-domain.xone
  • chainId: 使用的网络

返回:

  • 成功返回校验和地址字符串,失败返回 null

reverseResolveAddressToName

将链上地址反向解析为域名,支持可选前向验证。

函数签名:

reverseResolveAddressToName(
  addr: string,
  chainId: number,
  verifyForward?: boolean
): Promise<string | null>

参数:

  • addr: 链上地址(0x...)
  • chainId: 使用的网络
  • verifyForward: 默认 true。开启后会将域名再次正向解析为地址并与 addr 比较,只有一致才返回域名

返回:

  • 成功返回域名字符串,失败返回 null

resolveDomainToAddresses

基于 resolver.multicall 批量解析多个 coinType 的地址(仅返回有记录的条目)。

函数签名:

resolveDomainToAddresses(
  name: string,
  chainId: number,
  coinTypes?: number[]
): Promise<Record<string, string> | null>

参数:

  • name: 域名
  • chainId: 使用的网络
  • coinTypes: 可选,指定要解析的 coinType 列表。不传或空数组时,默认解析全部内置类型

返回:

  • 键为链名称(如 "Polygon"、"Ethereum"、"Solana")、值为地址字符串的对象;若全部为空或失败,返回 null

说明:

  • 对 EVM 系返回 0x 地址;对 Solana/Tron/Wiko 返回 base58 字符串
  • multicall 结果中的空 bytes(0x…0000)会被过滤,不会出现在返回对象里
  • 键使用链名称(来自 CoinType 枚举,如 "Polygon"、"Ethereum"、"BSC"、"Solana"、"Tron"),更易于识别

进阶说明

  • 返回值为 null 表示:域名不存在、未设置解析器或地址记录为空,或网络错误
  • 反向解析启用前向验证能提升安全性,建议在生产开启
  • 批量解析为只读调用(不发交易),网络不稳定时可重试

许可证

MIT