Skip to main content

Querying

Use the getNameRecord, getPriceList, and getRenewalPriceList methods to query onchain SuiNS name records, active registration pricing, and renewal costs.

caution

The examples on this page use SuinsClient. @mysten/suins 2.0 still exports it, but the suins() client extension is the preferred pattern. The method names are unchanged, but they now use client.suins. If you use the extension, call the same methods shown below on client.suins instead of suinsClient. See Migrating @mysten/suins.

Use the SuinsClient that you previously created to query onchain data. See the SuiNS SDK page for client setup.

How do I query a name record?​

You can query a name record's latest state by calling the getNameRecord method on the SuinsClient instance.

const nameRecord = await suinsClient.getNameRecord('demo.sui');
console.log(nameRecord);

// Example output
// {
// name: 'demo.sui',
// nftId: '0xMyNftId',
// targetAddress: '0xTargetAddress',
// expirationTimestampMs: '1746018571863',
// data: {
// avatar: '0xAvatarObjectId',
// contentHash: 'content',
// walrusSiteId: '0xWalrusSiteId',
// },
// avatar: '0xAvatarObjectId',
// contentHash: 'content',
// walrusSiteId: '0xWalrusSiteId',
// }

As the field name indicates, expirationTimestampMs is expressed in milliseconds.

How do I get active pricing?​

Call the getPriceList method on the SuinsClient instance to query the active names price list.

Each entry maps a [domain_length_from, domain_length_to] range to a price. To find the price for a name, use the entry whose range includes the name's length. Prices are in USDC MIST, where 1 USDC = 1_000_000 MIST. For example, in the output below, the [ 5, 63 ] entry of 20000000 MIST (20 USDC) applies to names with a length from 5 to 63.

const priceList = await suinsClient.getPriceList();
console.log(priceList);

// ([domain_length_from, domain_length_to]: price. Prices are in USDC MIST; 1 USDC = 1_000_000 MIST)
// Example output:
// {
// [ 3, 3 ] => 500000000,
// [ 4, 4 ] => 100000000,
// [ 5, 63 ] => 20000000
// }

How do I check renewal pricing?​

Call the getRenewalPriceList method on the SuinsClient instance to query the active renewal price list. The renewal price list uses the same range-to-price structure and USDC MIST units as the active price list.

const renewalPriceList = await suinsClient.getRenewalPriceList();
console.log(renewalPriceList);

// ([domain_length_from, domain_length_to]: price. Prices are in USDC MIST; 1 USDC = 1_000_000 MIST)
// Example output:
// {
// [ 3, 3 ] => 500000000,
// [ 4, 4 ] => 100000000,
// [ 5, 63 ] => 20000000
// }