The following code is used to retrieve all Sub-Domains of a Public-Key.

const getAllSNSProgramAccounts = async () => {
    const accounts = await connection.getProgramAccounts(new PublicKey('namesLPneVptA9Z5rqUDD9tMTWEJwofgaYwp8cawRkX'), {
        commitment: 'confirmed',
        encoding: 'base64',
        filters: [
                memcmp: {
                    offset: 32,
                    bytes: wallet.publicKey.toBase58(),
    console.log('All SNS Program Accounts (Domains+Subdomains): ', accounts);

Note: ATM I think one needs to manually resolve the the returned PKs to distinguish between domains and subdomains.

example result

Ref: https://sns.guide/domain-name/subdomains/index.html

1 Answer 1


This is correct in all cases -- domains also have the owner written after 32 bytes. Here's the only data used for SNS accounts: https://github.com/solana-labs/solana-program-library/blob/272bbe0b3dcf41989fd687aebaf67bb398e6c348/name-service/program/src/state.rs#L24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.