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

whoisens-lib

v1.0.2

Published

Whois for ENS (Ethereum Name Service) lookup service

Downloads

108

Readme

WhoisENS library

https://www.npmjs.com/package/whoisens-lib https://travis-ci.org/whoisens/whoisens-lib https://david-dm.org/whoisens/whoisens-lib https://david-dm.org/whoisens/whoisens-lib?type=dev https://packagephobia.now.sh/result?p=whoisens-lib https://github.com/whoisens/whoisens-lib/blob/master/LICENSE

Lightweight library with minimum dependencies to work with ENS (Ethereum Name Service).

Features

  • get owner/controller information
  • get name date expiration
  • resolve name to addresses and address to name
  • get contenthash (IPFS/Swarm)

Works with both browser and Node.js.

Library used by WhoisENS.org

PLEASE NOTE: whoisens-lib doesn't work with old ENS registrar (names registered via auction). These names should be migrated to new ENS registrar by May 4, 2020.

Advantages

  • advanced output. You can debug what contract was used, what method was called, what payload was passed and more other info
  • resolve method accept and resolves both names and addresses. You don't need to check it manually
  • content hash returns already decoded
  • lightweight
  • you can include it directly in your browser via <script>, for example you can't do it with Web3.js
  • thorough tests

How it works?

For more information, please read ENS (Ethereum Name Service): How it works?

Install

npm i whoisens-lib

Example of use

// In case running on Node.js, install and export globally `fetch`
import fetch from 'node-fetch';
global.fetch = fetch;

// basic constructor
const ens = new ENS();

// pass custom networkURL
const ens = new ENS({networkURL: 'https://eth.gateway.whoisens.org'});
const ens = new ENS({networkURL: 'https://mainnet.infura.io/v3/<YOUR_KEY>'});

// pass custom eth contractAddress
const ens = new ENS({contractAddress: '0x314159265dd8dbb310642f98f50c066173c1259b'});

// get name owner (registrar)
const ens = new ENS();
ens.init('whoisens.eth');
const result = await ens.getOwner();

// get name expiration date
const result = await ens.getExpirationDate();

// get controller
const result = await ens.getController();

// resolve name or address
const result = await ens.resolve();

// get content hash
const result = await ens.getContentHash();

Include library

ECMAScript Modules (Node.js or webpack)

import ENS, {ResolveType, EthAddressType, utils} from 'whoisens-lib';

It'll include default ESM module.

CommonJS (Node.js)

const WhoisENS = require('whoisens-lib/cjs/index.js');

const ENS = WhoisENS.default;
const {ResolveType, EthAddressType, utils} = WhoisENS;

Script (browser)

<script src="https://unpkg.com/whoisens-lib/dist/browser/main.js"></script>
<script>
  const ENS = WhoisENS.default;
  const {ResolveType, EthAddressType, utils} = WhoisENS;
</script>

REST API

If you don't willing to include any libraries, you can use WhoisENS REST API directly.

Build (development)

npm ci
npm build:watch

Build (production)

Will produce esm, cjs and bundle modules.

npm run build

Test

npm run test

Logs

Debug modules is used.