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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@anomsci/resolution

v1.0.0

Published

A simple resolution library for Ethereum Name Service (ENS) domains.

Downloads

7

Readme

Resolution

@anomsci/resolution | A simple resolution library for Ethereum Name Service (ENS) domains.

Getting Started

This library uses Node v20.16.0, with the core dependency for ENS name resolution being Ethers (v6.13.2). To get started, install the library:

npm install @anomsci/resolution

Usage

The most simple way to resolve a name is to import the resolve function from @anomsci/resolution, provide a name, then log the result to the console.

const { resolve } = require('@anomsci/resolution');

resolve('example.eth').then(console.log);

The resolution results for any name will contain information about the name ownership/management, the name's records (address, content, text), tokenId, wrapper status, and parent information (subnames only):

  • owner: Token holder address returned via an ownerOf() call to the ENS Name Wrapper or Registrar contract with the name's tokenId.
  • manager: Owner address returned via an owner() call to the ENS registry.
  • address: Address record returned via an addr() call to the name's resolver.
  • content: The decoded content hash returned via a contenthash() call to the name's resolver.
  • text: The text records based on the textKeys specified in config.yaml returned via a getText() call to the name's resolver.
  • tokenId: The calculated tokenId based on the namehash or labelhash of the name.
  • status: Name Wrapper status. Either wrapped or unwrapped.
  • parent: In cases of subname resolution, this corresponds to the token data of the parent name (e.g.. for the subname sub.example.eth, the parent is example.eth). The returned token data includes the owner, manager, tokenId, and status of the parent name.
{
  owner: 'OWNER_ADDRESS',
  manager: 'MANAGER_ADDRESS',
  address: 'ADDRESS_RECORD',
  content: {
    type: 'ipfs',
    name: 'IPFS_CID'
  },
  text: {
    avatar: 'AVATAR_URL',
    url: 'URL'
  },
  tokenId: 'TOKEN_ID',
  status: 'WRAPPER_STATUS',
  parent: {
    owner: 'PARENT_OWNER',
    manager: 'PARENT_MANAGER',
    tokenId: 'PARENT_TOKEN_ID',
    status: 'PARENT_WRAPPER_STATUS'
  }
}

Config

To use the resolve function, an Ethereum Mainnet connection is required. This is set through the RPC_URL variable in the .env, where you can specify your HTTP JSON-RPC provider URL.

# URL for your Ethereum Mainnet JSON RPC Interface
RPC_URL=<YOUR_RPC_URL>

The library can be configured from the config.yaml. This contains the ABI for the calls used to different contracts in the resolution process, contract addresses, the textKeys used for resolving text records, and name of the .env variable for the provider URL. By default, the config contains the ABI for the owner(), addr(), contenthash(), and ownerOf() calls, contract addresses for the ENS registry, name wrapper, and registrar, and text keys corresponding to the Global Keys specified under ERC-634: Storage of text records in ENS. The default .env variable name for the provider URL is RPC_URL.

ABI:
  registry:
    - "function owner(bytes32 node) external view returns (address)"
  resolver:
    - "function addr(bytes32) view returns (address)"
    - "function contenthash(bytes32) view returns (bytes)"
  name_wrapper:
    - "function ownerOf(uint256 id) view returns (address owner)"
  registrar:
    - "function ownerOf(uint256 tokenId) view returns (address)"

contracts:
  registry: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"
  name_wrapper: "0xD4416b13d2b3a9aBae7AcD5D6C2BbDBE25686401"
  registrar: "0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85"

textKeys:
  - "avatar"
  - "description"
  - "display"
  - "email"
  - "keywords"
  - "mail"
  - "notice"
  - "location"
  - "phone"
  - "url"

providerConfig:
  rpcEnv: "RPC_URL"