Skip to main content

SuiNS SDK

Install the SuiNS SDK with npm i @mysten/suins, then attach the suins() extension to a Sui client with $extend(). SuiNS methods are then available under client.suins.

Use the SuiNS SDK to interact with the Sui Name Service. Query SuiNS data in a usable way and build transactions that interact with service names.

To get started:

  1. Install the SDK.
  2. Attach the suins() extension to your Sui client.
  3. Call SuiNS methods under client.suins.

How do I install the SuiNS SDK?​

To use with the latest version of the TypeScript SDK, install using:

$ npm i @mysten/suins

What does the suins client extension do?​

The suins() extension adds SuiNS functionality to any Sui client, exposed under client.suins.

info

You should keep only 1 extended client throughout your app, API, or script. For example, in React, you should use a context to provide the client.

How do I add SuiNS methods to a Sui client?​

caution

Always keep the dependency updated so you get the latest constants. The SDK's built-in constants include the SuiNS package IDs for Mainnet and Testnet, and these change on every package upgrade. If you do not, some of your transactions might fail to build.

Attach SuiNS to a Sui client by passing the suins() extension to the client's $extend() method, which adds the SuiNS methods under client.suins. Pass no arguments to use the built-in constants for Mainnet and Testnet, or pass a packageInfo object to target any other deployment.

import { suins } from '@mysten/suins';
import { SuiGrpcClient } from '@mysten/sui/grpc';

// Re-use the Sui client of your project rather than creating a new one.
const client = new SuiGrpcClient({
network: 'testnet',
baseUrl: 'https://fullnode.testnet.sui.io:443',
}).$extend(suins());

// SuiNS methods are now available under client.suins.
const nameRecord = await client.suins.getNameRecord('example.sui');