Get all registered domains
Use the methods below to get all registered domain names in existence right now.
To avoid issues from the large payload response using the getAllDomainsmethod from the JS/TS SDK, only the domain owner information is returned.
import { getAllRegisteredDomains } from "@bonfida/spl-name-service";
const registeredDomains = await getAllRegisteredDomains(connection);If you prefer to use a call to getProgramAccounts an example of the call and the required filters is below.
const getAllRegisteredDomains = async (connection: Connection) => {
const filters = [
{
memcmp: {
offset: 0,
bytes: ROOT_DOMAIN_ACCOUNT.toBase58(),
},
},
];
const dataSlice = { offset: 32, length: 32 };
const accounts = await connection.getProgramAccounts(NAME_PROGRAM_ID, {
dataSlice,
filters,
});
return accounts;
};Last updated