Get all domains of wallet
Use the methods below to get all the domain names owned by a specific wallet address.
import { getAllDomains } from "@bonfida/spl-name-service";
const domains = await getAllDomains(connection, user);
The web3.js v1 version of the function above will return an array of public keys. Use the toBase58() method to convert the public keys into base 58 encoded strings. The web3.js v2 solana/kit version of the method returns an array of objects containing both the domain address as well as the domains in human readable string format.
Another option to retrieve public keys, as well as their corresponding domain names in a human readable string format is to use the function below which returns an array of objects including public keys, and their corresponding domain name strings.
import { getDomainKeysWithReverses } from "@bonfida/spl-name-service";
const domainsWithReverses = await getDomainKeysWithReverses(connection, user);
If you prefer to use a call to `getProgramAccounts`, you'll want to use the filters below.
const filters = [
{
memcmp: {
offset: 32,
bytes: user.toBase58(),
},
},
{
memcmp: {
offset: 0,
bytes: ROOT_DOMAIN_ACCOUNT.toBase58(),
},
},
];
Last updated