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

@ensdomains/ensjs

v5.2.10

Published

ENS javascript library for contract interaction

Readme

ENSjs

The ultimate ENS JavaScript library, with viem under the hood.

ENSjs is a TypeScript library for interacting with the Ethereum Name Service. It provides tree-shakeable, composable actions on top of viem, with first-class support for both ENS v1 and ENS v2.

Features

  • Composable actions that extend any viem Client
  • Full tree-shaking — pay only for the actions you import
  • Multicall batching for read actions
  • TypeScript-first, with strict types for chain contracts
  • ENS v1 + ENS v2 support side by side
  • Subgraph and DNS helpers included
  • Standalone @ensdomains/ensjs-abi package for ABI snippets

Monorepo layout

| Package | Description | | --- | --- | | @ensdomains/ensjs | Main library — actions, clients, utils | | @ensdomains/ensjs-abi | ABI snippets for every ENS contract (v1 + v2) | | @ensdomains/ensjs-react | React hooks built on @wagmi/core | | @ensdomains/ensjs-query-core | @wagmi/core query integration |

Supported chains: mainnet (1) and sepolia (11155111).

Installation

pnpm add @ensdomains/ensjs viem

You'll also need viem ≥ 2.9.2 as a peer dependency. Some features need optional peer dependencies:

| Package | Needed for | | --- | --- | | graphql | @ensdomains/ensjs/subgraph | | @ensdomains/dnsprovejs (^0.5.4 \|\| ^1.0.0) | getDnsImportData from @ensdomains/ensjs/dns |

Getting started

addEnsContracts extends a viem chain with all ENS contract addresses and subgraph URLs, so you can use it with any viem createPublicClient / createWalletClient.

import { http, createPublicClient } from 'viem'
import { mainnet } from 'viem/chains'
import { addEnsContracts } from '@ensdomains/ensjs'
import { getAddressRecord, getRecords } from '@ensdomains/ensjs/public'

const client = createPublicClient({
  chain: addEnsContracts(mainnet),
  transport: http(),
})

const eth = await getAddressRecord(client, { name: 'ens.eth' })
const records = await getRecords(client, {
  name: 'ens.eth',
  texts: ['com.twitter', 'avatar'],
  contentHash: true,
})

Entry points

The @ensdomains/ensjs package is split into subpath exports so bundlers can drop everything you don't import.

| Import | Contents | | --- | --- | | @ensdomains/ensjs | addEnsContracts, error classes | | @ensdomains/ensjs/public | Shared read actions (resolution, records, reverse, price, availability) | | @ensdomains/ensjs/public/v1 | v1-specific reads | | @ensdomains/ensjs/public/v2 | v2-specific reads | | @ensdomains/ensjs/wallet | Shared write actions (commit, register, renew, set individual records) | | @ensdomains/ensjs/wallet/v1 | v1-specific writes (wrap/unwrap, fuses, subnames, transfer, setRecords, primary name) | | @ensdomains/ensjs/wallet/v2 | v2-specific writes | | @ensdomains/ensjs/subgraph | Subgraph client + queries (getSubnames, getNamesForAddress, history, …) | | @ensdomains/ensjs/dns | DNS helpers (getDnsOwner, importDnsName, getDnsImportData, …) | | @ensdomains/ensjs/utils | Coders (getAddress, getText, getAbi, getContentHash), name utils | | @ensdomains/ensjs/utils/v2 | v2 utils (role encoding, resolver resources, canonical IDs) | | @ensdomains/ensjs/contracts | Re-exports of ABI snippets | | @ensdomains/ensjs/chain | Chain types and helpers (ChainWithEns, extendChainWithEns, getChainContractAddress) |

ABIs themselves are published as a standalone package and can be imported directly:

import { permissionedRegistryGetStateSnippet } from '@ensdomains/ensjs-abi/v2/permissionedRegistry'
import { ethRegistrarControllerRegisterSnippet } from '@ensdomains/ensjs-abi/v1/ethRegistrarController'

Action pattern

Every action is a plain function that takes the viem Client first and parameters second.

const result = await actionName(client, {
  /* params */
})

Read actions use getAction + readContract / multicall so they work with whatever batching configuration is on the client. Write actions return a transaction hash and accept the standard viem write parameters (account, chain, gas, etc.).

Development

# Install
pnpm install

# Build everything
pnpm -r build

# Build a single package
pnpm -F @ensdomains/ensjs build
pnpm -F @ensdomains/ensjs-abi build

# Lint (Biome)
pnpm lint

# Type check
pnpm -F @ensdomains/ensjs check:types

# Test the main package
pnpm -F @ensdomains/ensjs test
pnpm -F @ensdomains/ensjs test:watch
pnpm -F @ensdomains/ensjs test src/actions/public/resolver/getRecords.test.ts

# Generate the markdown docs
pnpm -F @ensdomains/ensjs generateDocs

# Versioning (changesets)
pnpm chgset:run
pnpm chgset:version

Tests run against a local devnet with the ENS contracts deployed and test names seeded (ghcr.io/ensdomains/contracts-v2), so Docker needs to be running. test starts the devnet via packages/ensjs/compose.yml and stops it afterwards. If one is already running on localhost:8545, it's reused:

docker compose -f packages/ensjs/compose.yml up -d devnet

Node ≥ 22 is required for the main packages (≥ 18 for query-core). Tooling: pnpm 12, TypeScript strict mode, Biome for formatting and linting, Vitest for tests.

Contributing

See CONTRIBUTING.md for guidance on adding new actions, wiring up new ABI snippets, registering new contract addresses, and the test conventions used across the repo.

Docs

Guides and the API reference live under docs/. The API reference is generated from the source JSDoc with pnpm -F @ensdomains/ensjs generateDocs.

License

MIT