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

@snsdomains/js

v3.0.36

Published

![test workflow](https://github.com/snsdomains/js/actions/workflows/tests.yml/badge.svg) [![npm version](https://badge.fury.io/js/@snsdomains%2Fjs.svg)](https://badge.fury.io/js/@snsdomains%2Fjs)

Downloads

68

Readme

@snsdomains/js

test workflow npm version

The Sui Name Service is a decentralized naming and identity protocol for the Sui Network. This package provides all the JavaScript resources to interact with the on-chain domains program. We are proudly open-source and community-run.

Install with npm:

$ npm install @snsdomains/js

Install with yarn:

$ yarn add @snsdomains/js

Quick start

For a quick start guide, please see the examples below. The library is very lightweight and actively used in our production software. If you require any on-boarding assistance or have a partnership requests, please email us at [email protected].

Sui Devnet

Please note that the Sui devnet updates will require us to update this library to work with the new deployed addresses. Luckily, this feature is built-in and you don't have to continuously update your addreses. Instead, it will fetch from our objects.json repository.

Built to Scale

The Sui Name Service domains program is built to scale to 100m+ names on-chain, by using the Sui dynamic object API. The API structure for domains is as follows:

  1. Resolver: Stores all domain text records and a reference to its ownership NFT. (Can be cached)
  2. Domain NFT: Represents ownership of the domain name. Whoever owns this NFT is automatically the resolvable address for the domain.
  3. Profile: Automatically created with a user's first domain registration (free of charge). This is used to reflect a user's identity on Sui and can be configured with all elements of their basic profile.

To prevent confusion, the DomainNFT owner will always be the resolvable address of the domain. This was done to prevent mis-transfers of funds following secondary sales, and the limited use cases associated with changing the resolvable address of a domain.

Examples

Resolve a domain in five lines of code! Below are listed all of our available query methods.

GET a Domain's SuiAddress

This is the core query of the Sui Name Service and resolves a domain to its owner. Our library is made to work whenever the Sui Network resets without you having to update to a new version. It automatically fetches our latest deployed program IDs from our Github.

import {SnsApi, queryForObjects} from '@snsdomains/js';
import {JsonRpcProvider, Network} from "@mysten/sui.js";

// *This is only required for dev-net.
// It fetches our program IDs without you having to update this library
const objects = await queryForObjects(Network.DEVNET);

// Configure API / provider
const provider = new JsonRpcProvider(Network.DEVNET);
const api = new SnsApi(provider, Network.DEVNET, objects);

// Resolve domain
const address = await api.domains.getAddress("anthony.sui");

GET an Ownership DomainNFT

const nft = await api.domains.getDomain("anthony.sui");

GET a DomainResolver

Domain name-service records are stored on the resolver. For consecutive queries of the same name, please cache the domain's Resolver and use it to re-query the domain address or records.

const resolver = await api.domains.getResolver("anthony.sui");

GET a user's Sui Profile

const userAddress = "0xc4173a804406a365e69dfb297d4eaaf002546ebd"
const profile = await api.profiles.getProfile(userAddress);

GET a user's Sui Primary Domain Name

const userAddress = "0xc4173a804406a365e69dfb297d4eaaf002546ebd"
const profile = await api.profiles.getProfile(userAddress);
const primary = await api.profiles.getPrimaryDomain(profile);

Versioning

  • 0.0.1 Increase: object.json update / and or readme.md
  • 0.1.0 Increase: feature update
  • 1.0.0 Increase: major / breaking changes