Primary Domains

Users have the ability to select a domain name as their "primary". If you are a developer and want to integrate SNS to your dApp it's recommended to always use the primary domain name to replace the user's public key.

Primary domains were previously called favorite domains. The naming change was made in version 3.0.0 of the SDK.

Get a primary domain

import { getPrimaryDomain } from "@bonfida/spl-name-service";

const { domain, reverse } = await getPrimaryDomain(connection, domainOwnerPublicKey);

Get multiple primary domains

To retrieve primary domains for a group of up to 100 users, we've created the getMultiplePrimaryDomains function in our JavaScript SDK. This function is optimized for network efficiency, making only four RPC calls, three of which are executed in parallel. The function returns a promise that resolves to an array of strings or undefined representing the primary domain, or lack thereof for each wallet passed to the function.

import { getMultiplePrimaryDomains } from "@bonfida/spl-name-service";

const wallets = [
  new PublicKey("3ogYncmMM5CmytsGCqKHydmXmKUZ6sGWvizkzqwT7zb1"),
  new PublicKey("FMmaHPDL47V1gXsfh9WjgAT7Er3dfDvarQubTU1Jxc1r"),
  // Public Keys of all the wallet addresses you're looking up a primary domain for (up to 100)
];

const primaryDomains = await getMultiplePrimaryDomains(connection, wallets);

Walkthrough

For a walkthrough tutorial on integrating Primary Domains into your dApps, check out the video below.

Last updated