Sui.

Post

Share your knowledge.

harry phan.
Jul 28, 2025
Expert Q&A

How to default suins name?

it's not possible to get the default suins name from an address with @mysten/suins compared to with @mysten/suins-toolkit, how are you guys doing now?

  • Sui
  • Architecture
0
11
Share
Comments
.

Answers

11
Thorfin.
Jul 31 2025, 12:25

Currently, with @mysten/suins, it's not possible to get the default SUI name from an address directly, unlike @mysten/suins-toolkit which offers the utility for fetching the default SUI name using their SDK methods.

In the @mysten/suins-toolkit, you can use the getDefaultName function, which allows you to fetch the default SUI name associated with an address.

Here's a general idea of how you might approach it using @mysten/suins-toolkit:

import { Suins } from "@mysten/suins-toolkit";

const suins = new Suins();
const address = "your_sui_address_here";

async function getDefaultSuiName() {
    const name = await suins.getDefaultName(address);
    console.log(name); // The default name associated with the address
}

getDefaultSuiName();

However, with @mysten/suins, you would need to retrieve the user’s registered name through other means, as it doesn’t expose such functionality natively. You could implement a workaround using a combination of the user’s address and external data sources or API calls, if possible.

Does that help clarify things?

8
Comments
.
Ashford.
Jul 31 2025, 08:08

It seems like you're trying to fetch the default SuiNS name associated with a specific address, and you're noticing a difference between the functionality provided by @mysten/suins and @mysten/suins-toolkit.

Difference Between @mysten/suins and @mysten/suins-toolkit

  1. @mysten/suins: This package is designed for interacting with Sui Name Service (SuiNS) and allows for registering, managing, and querying names. However, it might not have an out-of-the-box method for getting the default name associated with a given address directly.

  2. @mysten/suins-toolkit: This package provides higher-level utilities, which might include more user-friendly or predefined functions to fetch the default SuiNS name, like address-to-name mappings.

The issue you’re facing likely stems from the differences in how the two libraries expose functionality. @mysten/suins-toolkit might have additional abstractions or direct methods that make it easier to get the default name for an address, while @mysten/suins may require a more manual process or direct contract interaction.

Default Name Resolution Using @mysten/suins

Currently, @mysten/suins (the core package) does not have a direct function to get the default name associated with an address, but it is possible to query the registry manually using Sui RPC.

Here’s how you can resolve the default SuiNS name manually with @mysten/suins.

Steps to Fetch the Default SuiNS Name

  1. Query the Sui Name Registry: You need to check the Sui Name registry to get the mapping for the address. This would involve interacting with the contract that manages SuiNS names and performing a lookup for the address.

  2. Use @mysten/suins SDK for Address to Name Mapping: Here’s how you could query the Sui Name registry for the default name:

const { SuiClient } = require('@mysten/sui.js');
const { Suin } = require('@mysten/suins');

// Create a client to interact with Sui RPC
const suiClient = new SuiClient({ rpcUrl: 'https://testnet.sui.io/rpc' });

async function getDefaultName(address) {
    try {
        // Initialize the Suin instance
        const suin = new Suin(suiClient);

        // Query the name registry
        const name = await suin.getNameByAddress(address);
        console.log('Default SuiNS Name: ', name);
    } catch (error) {
        console.error('Error fetching default name:', error);
    }
}

// Example usage
getDefaultName('0x1234567890abcdef1234567890abcdef12345678');

3. Compare With @mysten/suins-toolkit

If you want to get default names more easily, @mysten/suins-toolkit might provide a simplified interface for querying the name by address. You can compare how it abstracts the process and whether it offers an easier way to access the default name for an address.

Example:

import { SuinsToolkit } from '@mysten/suins-toolkit';

const suinsToolkit = new SuinsToolkit({ rpcUrl: 'https://testnet.sui.io/rpc' });

async function getDefaultNameWithToolkit(address) {
    const name = await suinsToolkit.getDefaultName(address);
    console.log('Default Name with Toolkit:', name);
}

getDefaultNameWithToolkit('0x1234567890abcdef1234567890abcdef12345678');

4. Method Comparison

To summarize, the key difference is that @mysten/suins-toolkit simplifies the process and might have a built-in method for fetching the default name associated with an address, while @mysten/suins (the core package) may require manual querying of the registry or using lower-level functions.


Conclusion

  • @mysten/suins-toolkit is a more user-friendly library that might provide high-level methods for fetching the default SuiNS name.
  • @mysten/suins can still achieve this, but requires querying the Sui Name registry directly.
  • If you’re looking for simpler implementation, you may want to use @mysten/suins-toolkit.

For more accurate results, you can refer to Sui's official documentation or GitHub repositories to understand the latest supported methods for querying SuiNS names.

7
Comments
.
Paul.
Paul4340
Jul 31 2025, 09:54

It seems like you are referring to the Sui Naming Service (SUINS) and how to retrieve the default name associated with a Sui address.

Here’s a breakdown of the two tools you mentioned:

  1. @mysten/suins: This package does not provide a direct way to fetch the default name associated with a specific address. It’s more geared toward interacting with the SUINS system in a generalized way.

  2. @mysten/suins-toolkit: This toolkit allows you to query the default name associated with a Sui address, making it easier to resolve addresses to human-readable names. It typically includes functions like resolve to fetch the default name from the SUINS registry.

How to Handle This:

Since you cannot directly retrieve the default name from an address using @mysten/suins, the recommended method is to use @mysten/suins-toolkit to query the SUI Name Service and resolve the address to a name.

If you're sticking with @mysten/suins, you would have to create your own logic for fetching the default name, possibly by looking up the information using the toolkit's resolution methods or querying the Sui blockchain directly if you have access to the correct state data.

Example with @mysten/suins-toolkit (if needed):

const { getName } = require('@mysten/suins-toolkit');

async function getDefaultName(address) {
  try {
    const name = await getName(address); // Retrieves the default name for the Sui address
    console.log(`The default name for address ${address} is ${name}`);
  } catch (error) {
    console.error('Error fetching name:', error);
  }
}

If you're facing issues or need an alternative approach using @mysten/suins, we could explore how to set up a custom resolution method, or potentially how to use other Sui features to retrieve this information.

Let me know how you'd like to proceed!

7
Comments
.
Benjamin XDV.
Jul 29 2025, 13:33

Getting Default SUINS Name with @mysten/sui.js

import { SuinsClient } from '@mysten/sui.js/client';

const client = new SuinsClient();
const defaultName = await client.getDefaultName({
  address: '0x...',
  registry: '0xd22b24490e0bae52676651b4f56660a5ff8022a2576e0089f79b3c88d44e08f0' // Mainnet registry
});

Key Notes:

  1. Registry Addresses:

    • Mainnet: 0xd22b24490...e44e08f0
    • Testnet: 0x6e0ddefc0ad98889c04bab9639e512c21766c5e6366f89e696956d9be6952871
  2. Comparison to Toolkit:

    • The @mysten/sui.js method is more lightweight
    • @mysten/suins-toolkit includes caching and reverse lookups
  3. Error Handling:

    try {
      const name = await client.getDefaultName({ address, registry });
      console.log(name || 'No default name set');
    } catch (e) {
      console.error('SUINS lookup failed', e);
    }
    
5
Comments
.
theking.
Jul 28 2025, 11:36

You can fetch the default SuiNS name for an address using GraphQL, which currently offers a defaultSuinsName field on the account record. Unfortunately, the @mysten/suins SDK does not expose this out of the box, while the @mysten/suins-toolkit or GraphQL endpoint supports it directly. So if you're relying on suinsClient, you'll need to use GraphQL off-chain to read the defaultSuinsName associated with the address and then integrate that into your frontend or logic.

The GraphQL schema includes:

Account {
  defaultSuinsName(format: DomainFormat): String
}

which gives you the reverse lookup of the default SuiNS name bound to that wallet (github.com).

To summarize: You can't retrieve the default SuiNS name directly using only @mysten/suins client methods, but you can via GraphQL (or the toolkit). If you need, I can help you write a GraphQL query or integrate that lookup into your application.

3
Comments
.
BigSneh.
Jul 30 2025, 15:13

You're correct in noticing a distinction between @mysten/suins and @mysten/suins-toolkit when it comes to resolving a default SuiNS name from an address. As of mid-2024 and beyond, the recommended way to fetch the default SuiNS name is via the @mysten/suins-toolkit, because the core @mysten/suins package does not support resolving the default name directly from an address.


Why @mysten/suins Can't Do It Alone

The @mysten/suins package is a low-level resolver that:

  • Performs basic name-to-address lookups (forward resolution).
  • Supports reverse resolution only if you provide specific Sui object references.

It doesn't handle logic around "default" names — which requires resolving from name records, reverse records, and priority rules.


How @mysten/suins-toolkit Does It

The @mysten/suins-toolkit handles:

  • Fetching the full list of names owned by an address.
  • Checking the reverse record object.
  • Determining the default SuiNS name based on the protocol rules (e.g. reverse record + verification).

Here’s a simplified example:

import { getDefaultName } from '@mysten/suins-toolkit';
import { SuiClient } from '@mysten/sui.js/client';

const client = new SuiClient({ url: 'https://fullnode.testnet.sui.io' });

const address = '0xabc123...';

const defaultName = await getDefaultName(client, address);

console.log('Default SuiNS name:', defaultName);

This works because getDefaultName():

  • Queries the reverse record object from the chain.
  • Verifies it points to a name the user actually owns.
  • Returns it only if it passes the protocol checks.
3
Comments
.
Alya.
Alya-14
Jul 31 2025, 06:24

Use @mysten/suins with resolveName to get the default SUINS name from an address — it’s supported in latest versions. suins-toolkit had early shortcuts; now @mysten/suins is the standard.

3
Comments
.
MoonBags.
Sep 7 2025, 14:22

To get the default SuiNS name for an address, you should use the Sui GraphQL API, not the @mysten/suins package. The @mysten/suins package does not provide a direct way to fetch the default SuiNS name for an address, but the GraphQL API does.

How to Get the Default SuiNS Name for an Address

You can use the Sui GraphQL API and query the defaultSuinsName field on the Address object. Here’s an example GraphQL query:

{
  address(address: "0x0b86be5d779fac217b41d484b8040ad5145dc9ba0cba099d083c6cbda50d983e") {
    defaultSuinsName
  }
}
  • This will return the default SuiNS name (domain) configured for the given address, if it exists.

Reference:

Why Not @mysten/suins?

  • The @mysten/suins package is mainly for registering, managing, and resolving SuiNS names, but it does not expose the default name for an address.
  • The @mysten/suins-toolkit may have had some helper utilities, but the recommended and up-to-date way is to use the GraphQL API.
0
Comments
.

Do you know the answer?

Please log in and share it.