3.0.36 • Published 1 year ago

@snsdomains/js v3.0.36

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

@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 anthony@sns.domains.

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
3.0.34

1 year ago

3.0.35

1 year ago

3.0.33

1 year ago

3.0.36

1 year ago

3.0.24

1 year ago

3.0.28

1 year ago

3.0.25

1 year ago

3.0.26

1 year ago

3.0.32

1 year ago

3.0.30

1 year ago

3.0.31

1 year ago

3.0.29

1 year ago

2.2.0

1 year ago

3.0.12

1 year ago

3.0.4

1 year ago

3.0.13

1 year ago

3.0.3

1 year ago

3.0.10

1 year ago

3.0.2

1 year ago

3.0.11

1 year ago

3.0.1

1 year ago

3.0.16

1 year ago

3.0.8

1 year ago

3.0.17

1 year ago

3.0.7

1 year ago

3.0.14

1 year ago

3.0.6

1 year ago

3.0.15

1 year ago

3.0.5

1 year ago

3.0.0

1 year ago

3.0.23

1 year ago

3.0.21

1 year ago

3.0.22

1 year ago

3.0.20

1 year ago

3.0.18

1 year ago

3.0.19

1 year ago

3.0.9

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

2.1.2

1 year ago

2.0.3

1 year ago

2.1.1

1 year ago

2.0.2

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

2.0.11

1 year ago

2.0.7

1 year ago

2.0.6

1 year ago

2.0.9

1 year ago

2.0.10

1 year ago

2.0.8

1 year ago

2.1.0

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

0.4.14

2 years ago

0.4.13

2 years ago

0.4.12

2 years ago

0.4.11

2 years ago

0.4.10

2 years ago

0.4.9

2 years ago

0.4.8

2 years ago

0.4.7

2 years ago

0.4.6

2 years ago

0.4.5

2 years ago

0.4.4

2 years ago

0.4.3

2 years ago

0.4.2

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.8

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago