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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@pharosnames/pnsjs

v1.0.4

Published

Pharos Name Service (PNS) JavaScript library

Downloads

53

Readme

@pharosnames/pnsjs

The Pharos Name Service (PNS) JavaScript library provides a comprehensive interface for interacting with the Pharos Name Service, a decentralized naming system built on the Pharos blockchain. PNSJS is built on top of the popular ENSJS library, adapted specifically for the Pharos network using .phrs domains.

Features

  • 🔗 Resolve PNS names to addresses and vice versa
  • 📝 Manage text records (email, url, description, etc.)
  • 🌐 Multi-coin address resolution
  • 🛠️ Full TypeScript support
  • 📦 Built on proven ENSJS architecture with ENSJS compatibility
  • ⚡ Pharos testnet support
  • 🔐 Address encoder for 100+ cryptocurrencies

Installation

npm install @pharosnames/pnsjs

Quick Start

import { http } from "viem";
import { createEnsPublicClient } from "@pharosnames/pnsjs";
import { pharosTestnetChain } from "@pharosnames/pnsjs/contracts";
import { evmCoinNameToTypeMap } from "@pharosnames/address-encoder";

const PHAROS_COIN_TYPE = evmCoinNameToTypeMap["phrs"];

const client = createEnsPublicClient({
  chain: pharosTestnetChain,
  transport: http(),
});

(async () => {
  // Check if a name is available
  const available = await client.getAvailable({
    name: "test.phrs",
  });
  console.log("Available:", available);

  // Get address record
  const address = await client.getAddressRecord({
    name: "test.phrs",
    coin: PHAROS_COIN_TYPE,
  });
  console.log("Address:", address);

  // Reverse resolution - get name from address
  const name = await client.getName({
    address: "0x1234567890123456789012345678901234567890",
  });
  console.log("Name:", name);
})();

API Reference

Creating a Client

Create a public client for read operations:

import { createEnsPublicClient } from "@pharosnames/pnsjs";
import { pharosTestnetChain } from "@pharosnames/pnsjs/contracts";

const client = createEnsPublicClient({
  chain: pharosTestnetChain,
  transport: http("https://your-rpc-url"),
});

Core Functions

Name Availability

Check if a .phrs name is available for registration:

const available = await client.getAvailable({
  name: "example.phrs",
});
console.log(available); // true/false

Address Resolution

Get address for a name and reverse resolution:

import { evmCoinNameToTypeMap } from "@pharosnames/address-encoder";

const PHAROS_COIN_TYPE = evmCoinNameToTypeMap["phrs"];

// Get Pharos address for a name
const address = await client.getAddressRecord({
  name: "example.phrs",
  coin: PHAROS_COIN_TYPE,
});

// Get name for an address (reverse resolution)
const name = await client.getName({
  address: "0x1234567890123456789012345678901234567890",
});

Multi-Coin Support

Get addresses for different cryptocurrencies:

import { evmCoinNameToTypeMap } from "@pharosnames/address-encoder";

// Get Bitcoin address
const btcAddress = await client.getAddressRecord({
  name: "example.phrs",
  coin: evmCoinNameToTypeMap["btc"],
});

// Get Ethereum address
const ethAddress = await client.getAddressRecord({
  name: "example.phrs",
  coin: evmCoinNameToTypeMap["eth"],
});

Text Records and Multiple Records

Get text records and multiple record types at once:

// Get multiple records in one call
const records = await client.getRecords({
  name: "example.phrs",
  texts: ["description", "url", "email"],
  coins: [PHAROS_COIN_TYPE],
});

console.log(records.texts); // { description: "...", url: "...", email: "..." }
console.log(records.coins); // [{ id: 2148172336, name: "phrs", value: "0x..." }]

Address Encoder Integration

PNSJS includes full address encoder functionality with built-in support for Pharos and 100+ other cryptocurrencies:

import {
  getCoderByCoinName,
  getCoderByCoinType,
  coinTypeToNameMap,
  coinNameToTypeMap,
  evmCoinNameToTypeMap,
} from "@pharosnames/address-encoder";

// Get Pharos coin type
const PHAROS_COIN_TYPE = evmCoinNameToTypeMap["phrs"]; // 2148172336

// Get coder by coin name
const pharosCoder = getCoderByCoinName("phrs");
console.log(pharosCoder.coinType); // 2148172336
console.log(pharosCoder.name); // "phrs"

// Access coin type mappings
console.log(coinTypeToNameMap["2148172336"]); // ["phrs", "Pharos"]
console.log(coinNameToTypeMap["phrs"]); // 2148172336

Network Configuration

Pharos Testnet

The library comes with Pharos testnet configuration:

import { pharosTestnetChain } from "@pharosnames/pnsjs/contracts";

const client = createEnsPublicClient({
  chain: pharosTestnetChain,
  transport: http("https://pharos-testnet-rpc-url"),
});

Examples

Complete Example

import { http } from "viem";
import { createEnsPublicClient } from "@pharosnames/pnsjs";
import { pharosTestnetChain } from "@pharosnames/pnsjs/contracts";
import { evmCoinNameToTypeMap } from "@pharosnames/address-encoder";

const PHAROS_COIN_TYPE = evmCoinNameToTypeMap["phrs"];

// continue to use createEnsPublicClient for better compatibility with ensjs
const client = createEnsPublicClient({
  chain: pharosTestnetChain,
  transport: http(),
});

async function demonstratePNS() {
  try {
    // Check if a name is available
    const available = await client.getAvailable({
      name: "myname.phrs",
    });
    console.log("Available:", available);

    // Get address record
    const address = await client.getAddressRecord({
      name: "myname.phrs",
      coin: PHAROS_COIN_TYPE,
    });
    console.log("Address Record:", address);

    // Reverse resolution
    const name = await client.getName({
      address: "0x1234567890123456789012345678901234567890",
    });
    console.log("Name:", name);

    // Get multiple records
    const records = await client.getRecords({
      name: "myname.phrs",
      texts: ["description", "url"],
      coins: [PHAROS_COIN_TYPE],
    });
    console.log("Text Records:", records.texts);
    console.log("Coin Records:", records.coins);
  } catch (error) {
    console.error("Error:", error);
  }
}

demonstratePNS();

Multi-Coin Address Resolution

import { evmCoinNameToTypeMap } from "@pharosnames/address-encoder";

async function getMultiCoinAddresses() {
  const name = "example.phrs";

  // Get addresses for different cryptocurrencies
  const pharosAddress = await client.getAddressRecord({
    name,
    coin: evmCoinNameToTypeMap["phrs"],
  });

  const bitcoinAddress = await client.getAddressRecord({
    name,
    coin: evmCoinNameToTypeMap["btc"],
  });

  const ethereumAddress = await client.getAddressRecord({
    name,
    coin: evmCoinNameToTypeMap["eth"],
  });

  const polygonAddress = await client.getAddressRecord({
    name,
    coin: evmCoinNameToTypeMap["matic"],
  });

  console.log({
    pharos: pharosAddress,
    bitcoin: bitcoinAddress,
    ethereum: ethereumAddress,
    polygonAddress: polygonAddress,
  });
}

getMultiCoinAddresses();

License

MIT License